Jump to content

Strange TimerInit stubbornness


Go to solution Solved by MyEarth,

Recommended Posts

Posted

Hi all!

Local $search = _IEGetObjById($oIE, "header")
   Local $timer = TimerInit()
   ConsoleWrite(TimerDiff($timer) & @LF)
   Local $display = StringInStr($search.innerhtml, "display: block;")
   While $display = 0
      If TimerDiff($search) > 5000 Then
         ConsoleWrite("Time out after " & TimerDiff($search) & " ms!!" & @LF)
         Exit
      Else
         $display = StringInStr($search.innerhtml, "display: block;")
      EndIf
   WEnd

 Is a part of a really, long code project I am working on, this is the console message this gives me:

 

0.00192438451768509

Time out after 354672803.592826 ms!!

 

Anyone knows why this happens, and more importantly, where I've been a dum dum? Because I can't see it! It's always the programmers fault not the program itself, but this is really stretching that saying in my opinion!

  • Moderators
Posted

Sodori,

 

It's always the programmers fault not the program itself

Seems a perfectly reasonable statement to me: ;)

; Declaring variables
Local $search = _IEGetObjById($oIE, "header") ; Object
Local $timer = TimerInit()                    ; Timestamp

; Determining time difference
ConsoleWrite(TimerDiff($timer) & @LF)         ; Timestamp

If TimerDiff($search) > 5000 Then             ; Object ??????
    ConsoleWrite("Time out after " & TimerDiff($search) & " ms!!" & @LF)
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

Sodori,

 

Seems a perfectly reasonable statement to me: ;)

; Declaring variables
Local $search = _IEGetObjById($oIE, "header") ; Object
Local $timer = TimerInit()                    ; Timestamp

; Determining time difference
ConsoleWrite(TimerDiff($timer) & @LF)         ; Timestamp

If TimerDiff($search) > 5000 Then             ; Object ??????
    ConsoleWrite("Time out after " & TimerDiff($search) & " ms!!" & @LF)
M23

 

 

I am sorry, M23? xD The If statement is pretty much a artificial timeout. If the program can't find the object within 5 seconds, then nothing will happen. Else, it will exit out of the while loop thus render the if forgotten. Sorry that I didn't mention this before  :ermm: Let's just blame Monday mornings?  :)

 

Edit: Seems MyEarth is the hero here.. or the ninja rep stealer from Melba (not that you need it ;))

Local $search = _IEGetObjById($oIE, "header")
   $timer = TimerInit()
   ConsoleWrite(TimerDiff($timer) & @LF)
   Local $display = StringInStr($search.innerhtml, "display: block;")
   While $display = 0
      Local $diff = TimerDiff($timer)
      If $diff > 5000 Then
         ConsoleWrite("Time out after " & TimerDiff($search) & " ms!!" & @LF)
         Exit
      Else
         ConsoleWrite("Not yet! Time passed: " & $diff & @LF)
         $display = StringInStr($search.innerhtml, "display: block;")
      EndIf
   WEnd

Make a $diff value instead did the trick. Really can't comprehend why it would add about 300,000 seconds to the $timer unless I did that. But oh well, thanks!

Edited by Sodori
  • Moderators
Posted

Sodori,

The point I was trying to make is that you are using the wrong variable in the If TimerDiff statement - I was obviously too oblique for a Monday morning. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

Quite it is Melba xD Sorry it's Monday morning, I got a metric ton of stuff in my head not to mention trying to get back into my lines after a weekend of forgetfulness, regrets and a bit of headache. I still ain't too sure that you are insinuating. But Earth helped me, I hope what he said was pretty much close enough to what you menth :P

PS. Did edit my post #5, unless noticed.

PPS. I am editing my posts way too much, I need to stop this and get my head away from here xD

Edited by Sodori
Posted

@MyEarth - Do you think there might be a reason for M23 to respond as he did???

 

Do you think i see it? I was write the post when Melba post it 2 minutes ( not 10 minutes, 1 hour or 10 hours ) before mine, come'on you are a MVP i don't need to tell you "think before post", or not? :D

Posted (edited)

You must understand MyEarth, since it's Monday he might be a bit high on coffee or any other sugar related liquid :) 2 min for you probably 20 hours for him ^^ It's a thesis though! :D

Edited by Sodori
Posted

@Sodori - Yes, not enough coffee on Earth at 3:55 AM...The important point is for you to see that $search was the wrong var to use in TimerDiff().

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

Oh, goodness me xD Yes, yes that is slight wrong way to use it >.< Kinda needs a second pair of brains here at my work who understands AutoIt, maybe then I can sort such embarrassing things out on my own xD Thank you all! I am such a dum dum sometimes.. Were looking at that line for about three hours last Friday, only to not even solve it after a weekends rest..

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...