dragonlord Posted November 20, 2012 Share Posted November 20, 2012 Morning: User comes online : Timervar=TimerInit() User goes offline : TimerDiff(Timervar) Print the time for which user was online Noon: User comes online : Timervar=TimerInit() User goes offline : TimerDiff(Timervar) Print the time for which user was online Evening: User comes online : Timervar=TimerInit() User goes offline : TimerDiff(Timervar) Print the time for which user was online -I need to figure how much time a user was online during an entire day(total time). Adding up all the above 3 TimerDiff variables and converting them using _TicksToTime seems to be giving gibberish. Any thoughts please ? .... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 20, 2012 Moderators Share Posted November 20, 2012 dragonlord, I would expect this script to give an answer of about 3000: $iBegin = TimerInit() Sleep(1000) $nInterval_1 = TimerDiff($iBegin) $iBegin = TimerInit() Sleep(1000) $nInterval_2 = TimerDiff($iBegin) $iBegin = TimerInit() Sleep(1000) $nInterval_3 = TimerDiff($iBegin) $nTotal = $nInterval_1 + $nInterval_2 + $nInterval_3 ConsoleWrite($nTotal & @CRLF) And that is what it does. Perhaps if you posted your script we might be able to spot a problem. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
dany Posted November 20, 2012 Share Posted November 20, 2012 And if I take Melba23's code and plugin _TicksToTime I get 00:00:03 Global $iHour, $iMin, $iSec $nTotal = $nInterval_1 + $nInterval_2 + $nInterval_3 _TicksToTime($nTotal, $iHour, $iMin, $iSec) MsgBox(0, '', $nTotal & @CRLF & StringFormat('%02i:%02i:%02i', $iHour, $iMin, $iSec)) So yea, we'll need a bit more info. [center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF Link to comment Share on other sites More sharing options...
dragonlord Posted November 20, 2012 Author Share Posted November 20, 2012 (edited) Thanks melba23, Prodigy for your suggestions. Below's the code where i'm trying to do this. Now i understand what youre trying to tell, but i'm getting lost in my own code, its a mess. Still trying to figure out what i'm doing wrong.... (Search for the line which says "resetting time to 0". the problem area is the few lines below that....) expandcollapse popup#include <GUIConstants.au3> #include <Constants.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <GuiComboBox.au3> #include <GuiComboBoxEx.au3> #include <Date.au3> #include <String.au3> Dim $UserArray[1][2] Dim $TimeArray[1][2] Dim $TotalTimeArray[1][2] Dim $ItemsFromLV Dim $begin,$CurrColor,$StartCtr,$col2,$col3, $iHours, $iMins, $iSecs,$iHours2, $iMins2, $iSecs2,$tHours, $tMins, $tSecs Global $testCtr=0 $Green=0x98FB98 $Gray=0xEEDFCC $Red=0xFF6A6A $LVM_FIRST1 = 0x1000 $LVM_SCROLL1 = ($LVM_FIRST1 + 20) $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $oCommunicator = ObjCreate("Communicator.UIAutomation") If Not IsObj($oCommunicator ) Then MsgBox(48,"Error","l;llkklk") EndIf If @error then MsgBox(48,"Error","l;llkklk") EndIf #Region ### Start First Tab $Form1_1 = GUICreate("Time Cop", 615, 550, -1, -1) $Tab1 = GUICtrlCreateTab(8, 8, 601, 535) $TabSheet1 = GUICtrlCreateTabItem("Monitor") GUICtrlCreateLabel("user@domain.com : ", 32, 59, 101, 17) $emailInp = GUICtrlCreateInput("gil.ipe@mycompany.com", 136, 56, 153, 21) GUICtrlCreateLabel("Monitored Users: ", 380, 35, 101, 17) $mylist = GUICtrlCreateList("", 380, 50, 220, 125, -1, 0) $CurrentStatusLV = GUICtrlCreateListView("Time|User|Previous|Current", 16, 184, 586, 350, -1, Bitor($LVS_EX_GRIDLINES,$LVS_EX_HEADERDRAGDROP,$LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 120) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 100) $Button1 = GUICtrlCreateButton("Monitor User", 136, 88, 155, 25) $TabSheet2 = GUICtrlCreateTabItem("Extras") $AlertMe_Chk=GUICtrlCreateCheckbox ( "Alert when someone is away for more than ", 32, 50 ) $AlertMe_Inp=GUICtrlCreateInput("30",250,50,40) GUICtrlCreateUpdown($AlertMe_Inp); GUICtrlCreateLabel(" minutes ", 290,54) $AwayTimeLV = GUICtrlCreateListView("User|Current Away time|Total Away time Today", 16, 184, 586, 350, -1, Bitor($LVS_EX_GRIDLINES,$LVS_EX_HEADERDRAGDROP,$LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 220) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 200) $Button3 = GUICtrlCreateButton("Export to Excel", 509, 92, 83, 25) GUICtrlCreateTabItem("") $Button4 = GUICtrlCreateButton("About", 533, 1, 75, 25) LoadUsersFromFile() GUISetState() While 1 sleep(10) $nMsg = GUIGetMsg() FOR $i=0 to UBound($UserArray,1)-1 $element=$UserArray[$i][0] if (StringLen($element) > 0) And ($element<> "user@mycompany.com") Then $PrevStatus=$UserArray[$i][1] $CurrStatus=_getContactStatus($element) If $CurrStatus <> $PrevStatus Then GuiCtrlCreateListViewItem(@MON &"/"& @MDAY &"/"& @YEAR & " " & @HOUR &":"& @MIN &":"& @SEC & "|" &_StringProper(StringReplace ( $element, "@mycompany.com", ""))&"|"&$PrevStatus&"|"&$CurrStatus,$CurrentStatusLV) If $CurrStatus="ONLINE" or $CurrStatus="BUSY" Then $CurrColor=$Green EndIf If $CurrStatus="OFFLINE" or $CurrStatus="APPEARING OFFLINE" Then $CurrColor=$Red EndIf If $CurrStatus="UNKNOWN" or $CurrStatus="INACTIVE" or $CurrStatus="AWAY" or $CurrStatus="BE RIGHT BACK" Then $CurrColor=$Gray EndIf GUICtrlSetBkColor(-1, $CurrColor) GUICtrlSendMsg($CurrentStatusLV, $LVM_SCROLL1, 0, 250) $UserArray[$i][1]=$CurrStatus If $CurrColor=$Green Then $foundAt=_ArraySearch($TimeArray, $element ,0 ,0 ,0,0,1, 0) If Not @error Then _TicksToTime(TimerDiff($TimeArray[$foundAt][1]), $iHours, $iMins, $iSecs) ConsoleWrite("resetting time to 0 for "&$element&". Need to save previous ticks "&$TimeArray[$foundAt][1]&" which is "&$iHours&":"&$iMins&":"&$iSecs) $TotalTimeArray[$foundAt][1]=$TotalTimeArray[$foundAt][1]+$TimeArray[$foundAt][1] _TicksToTime(TimerDiff($TotalTimeArray[$foundAt][1]), $iHours, $iMins, $iSecs) ConsoleWrite(", Cumulative value = "&$TimeArray[$foundAt][1]&" which is "&$iHours&":"&$iMins&":"&$iSecs&@CRLF) $TimeArray[$foundAt][1]=0 EndIf Else $foundAt=_ArraySearch($TimeArray, $element ,0 ,0 ,0,0,1, 0) If Not @error Then $TimeArray[$foundAt][1]=TimerInit() EndIf EndIf EndIf EndIf NEXT FOR $i=0 to UBound($TimeArray,1)-2 if $TimeArray[$i][1]=0 then $col2="Online" Else _TicksToTime(TimerDiff($TimeArray[$i][1]), $iHours, $iMins, $iSecs) $col2=$iHours&":"&$iMins&":"&$iSecs If $TotalTimeArray[$i][1]<>0 Then _TicksToTime(TimerDiff($TotalTimeArray[$i][1]), $iHours, $iMins, $iSecs) $col3=$iHours&":"&$iMins&":"&$iSecs Else $col3="00:00:00" EndIf EndIf $iI = _GUICtrlListView_FindText($AwayTimeLV, StringUpper(StringReplace ( $TimeArray[$i][0], "@mycompany.com", ""))) _GUICtrlListView_SetItemText($AwayTimeLV, $iI,$col2,1) _GUICtrlListView_SetItemText($AwayTimeLV, $iI,$col3,2) If GUICtrlRead($AlertMe_Chk)=1 Then If $iMins>= GUICtrlRead($AlertMe_Inp) Then ;TrayTip("Away Alert", $TimeArray[$i][0] &" is away for "&$iMins&" minutes", 1, 1) EndIf EndIf Next Select Case $nmsg = $GUI_EVENT_CLOSE ExitLoop Case $nmsg = $button1 AddNewUser(GUICtrlRead($emailInp)) Case $nmsg = $button3 _GUICtrlListView_SaveCSV($CurrentStatusLV, @ScriptDir & "Export.csv") Case $nmsg = $Tab1 Case $nmsg = $AlertMe_Chk If GUICtrlRead($AlertMe_Chk)=1 Then TrayTip("Away Alert", "Set to "&GUICtrlRead($AlertMe_Inp)&" minutes", 1, 1) Else TrayTip("Away Alert", "Disabled", 1, 1) EndIf EndSelect WEnd Func _getContactStatus($contactName) $m = $oCommunicator.GetContact($contactName, $oCommunicator.MyServiceID) if @error Then MsgBox(4096,"","Error resolving contact information !") EndIf $statusName = _GetStatusName($m.Status()) return $statusName EndFunc func _GetStatusName($var) ;add code for In Meeting and Do not Disturb Switch $var Case 0 return "UNKNOWN" Case 1 return "OFFLINE" Case 2 return "ONLINE" Case 10 return "BUSY" Case 18 return "INACTIVE" Case 34 return "AWAY" Case 14 return "BE RIGHT BACK" Case 6 return "APPEARING OFFLINE" EndSwitch EndFunc Func _IsExistingUser($searchStr) local $found =-1 FOR $x=0 to UBound($UserArray,1)-1 FOR $y=0 to UBound($UserArray,2)-1 if $searchStr = $UserArray[$x][$y] Then $found=1 EndIf Next Next return $found EndFunc Func _GUICtrlListView_SaveCSV($hListView, $sFile, $sDelimiter = ",", $sQuote = '"') Local $hFileOpen, $iError = 0, $sItem, $sString Local $iColumnCount = _GUICtrlListView_GetColumnCount($hListView) Local $iItemCount = _GUICtrlListView_GetItemCount($hListView) For $A = 0 To $iItemCount - 1 For $B = 0 To $iColumnCount - 1 $sItem = _GUICtrlListView_GetItemText($hListView, $A, $B) $sString &= $sQuote & StringReplace($sItem, $sQuote, $sQuote & $sQuote, 0, 1) & $sQuote If $B < $iColumnCount - 1 Then $sString &= $sDelimiter EndIf Next $sString &= @CRLF Next $hFileOpen = FileOpen($sFile, 2) FileWrite($hFileOpen, $sString) FileClose($hFileOpen) If @error Then $iError = 1 EndIf Return SetError($iError, 0, $sFile) EndFunc Func LoadUsersFromFile() Local $var = IniReadSection(@ScriptDir&"Timecop.ini", "UserList") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $var[0][0] If $var[$i][0]="User" Then AddNewUser($var[$i][1]) EndIf Next EndIf EndFunc Func AddNewUser($userId) $CurrentUser=$userId If not StringInStr ($CurrentUser, "@mycompany.com") Then MsgBox(48,"Error","Invalid email") Else $search=_IsExistingUser($CurrentUser) if $search=-1 Then if _getContactStatus($CurrentUser)="UNKNOWN" Then MsgBox(16,"Error","Unable to get Communicator status. Please ensure " &$CurrentUser& " is valid !") Else $CurrStatus=_getContactStatus($CurrentUser) GUICtrlSetData($mylist,$CurrentUser&"|") $UserArray[UBound($UserArray,1)-1][0]=$CurrentUser $UserArray[UBound($UserArray,1)-1][1]=$CurrStatus ReDim $UserArray[UBound($UserArray,1)+1][2] GuiCtrlCreateListViewItem(@MON &"/"& @MDAY &"/"& @YEAR & " " & @HOUR &":"& @MIN &":"& @SEC & "|" &_StringProper(StringReplace($CurrentUser,"@mycompany.com", ""))&"| |"&$CurrStatus,$CurrentStatusLV) $TimeArray[UBound($TimeArray,1)-1][0]=$CurrentUser $TimeArray[UBound($TimeArray,1)-1][1]=0 $TotalTimeArray[UBound($TotalTimeArray,1)-1][0]=$CurrentUser $TotalTimeArray[UBound($TotalTimeArray,1)-1][1]=0 If $CurrStatus="ONLINE" or $CurrStatus="BUSY" Then $CurrColor=$Green If $CurrStatus="OFFLINE" or $CurrStatus="APPEARING OFFLINE" Then $CurrColor=$Red If $CurrStatus="UNKNOWN" or $CurrStatus="INACTIVE" or $CurrStatus="AWAY" or $CurrStatus="BE RIGHT BACK" Then $CurrColor=$Gray If $CurrColor<>$Green Then $TimeArray[UBound($TimeArray,1)-1][1]=TimerInit() ;$TotalTimeArray[UBound($TimeArray,1)-1][1]=TimerInit() EndIf If $CurrColor=$Green Then $TimeArray[UBound($TimeArray,1)-1][1]=0 ;$TotalTimeArray[UBound($TimeArray,1)-1][1]=0 EndIf ReDim $TimeArray[UBound($TimeArray,1)+1][2] ReDim $TotalTimeArray[UBound($TotalTimeArray,1)+1][2] GUICtrlSetBkColor(-1, $CurrColor) GUICtrlSendMsg($CurrentStatusLV, $LVM_SCROLL1, 0, 250) GuiCtrlCreateListViewItem(_StringProper(StringReplace ( $CurrentUser, "@mycompany.com", ""))&"|0",$AwayTimeLV) EndIf Else EndIf EndIf EndFunc Func _GUICtrlListView_CreateArray($hListView, $sDelimeter = '|') Local $iColumnCount = _GUICtrlListView_GetColumnCount($hListView), $iDim = 0, $iItemCount = _GUICtrlListView_GetItemCount($hListView) If $iColumnCount < 3 Then $iDim = 3 - $iColumnCount EndIf If $sDelimeter = Default Then $sDelimeter = '|' EndIf Local $aColumns = 0, $aReturn[$iItemCount + 1][$iColumnCount + $iDim] = [[$iItemCount, $iColumnCount, '']] For $i = 0 To $iColumnCount - 1 $aColumns = _GUICtrlListView_GetColumn($hListView, $i) $aReturn[0][2] &= $aColumns[5] & $sDelimeter Next $aReturn[0][2] = StringTrimRight($aReturn[0][2], StringLen($sDelimeter)) For $i = 0 To $iItemCount - 1 For $j = 0 To $iColumnCount - 1 $aReturn[$i + 1][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j) Next Next Return SetError(Number($aReturn[0][0] = 0), 0, $aReturn) EndFunc Func MyErrFunc() $HexNumber=hex($oMyError.number,8) if $HexNumber=80020009 Then Msgbox(48,"Time Cop","You are not signed in to Office Communicator !") Exit Else Msgbox(0,"","Intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) EndIf Endfunc Edited November 20, 2012 by dragonlord Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 20, 2012 Moderators Share Posted November 20, 2012 dragonlord, Although I cannot run your script, it looks to me as if the problem lies in this section: If Not @error Then ; Here you work out the time the user was online using TimerDiff <<<<<<<<<<<<<<<<<<<<<<<<<<<< _TicksToTime(TimerDiff($TimeArray[$foundAt][1]), $iHours, $iMins, $iSecs) ConsoleWrite("resetting time to 0 for " & $element & ". Need to save previous ticks " & $TimeArray[$foundAt][1] & " which is " & $iHours & ":" & $iMins & ":" & $iSecs) ; And here you add that value to the total <<<<<<<<<<<<<<<<<<<<<<<<<< $TotalTimeArray[$foundAt][1] = $TotalTimeArray[$foundAt][1] + $TimeArray[$foundAt][1] ; But why are you again using TimerDiff here? Surely you just need the _TicksToTime? <<<<<<<<<<<<<<<<<<< _TicksToTime(TimerDiff($TotalTimeArray[$foundAt][1]), $iHours, $iMins, $iSecs) ConsoleWrite(", Cumulative value = " & $TimeArray[$foundAt][1] & " which is " & $iHours & ":" & $iMins & ":" & $iSecs & @CRLF) $TimeArray[$foundAt][1] = 0 EndIf Try that and see if it works. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
dragonlord Posted November 20, 2012 Author Share Posted November 20, 2012 (edited) and this is what i get resetting time to 0 for gil.ipe. Need to save previous ticks 1028567859857 which is 0:0:7, Cumulative value = 1028567859857 which is 285713:17:39 resetting time to 0 for gil.ipe. Need to save previous ticks 1028654428933 which is 0:0:11, Cumulative value = 1028654428933 which is 571450:38:8 The Cumulative value and its HH:MM::SS values are super weird Edited November 20, 2012 by dragonlord Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 20, 2012 Moderators Share Posted November 20, 2012 dragonlord,So where do you actually save the number of ticks that you have worked out? That value of 1028567859857 looks like the return from TimerInit and not the return from TimerDiff. Perhaps you need to do something like this:If Not @error Then ; How long was the user online? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $nLength = TimerDiff($TimeArray[$foundAt][1]) ; And save it - you no longer need the initial timestamp <<<<<<<<<<<<<<<<<<<<<<<< $TimeArray[$foundAt][1] ; Convert it to HH:MM:SS for humans <<<<<<<<<<<<<<<<<<<<<<<<<< _TicksToTime($nLength, $iHours, $iMins, $iSecs) ConsoleWrite("resetting time to 0 for " & $element & ". Need to save previous ticks " & $TimeArray[$foundAt][1] & " which is " & $iHours & ":" & $iMins & ":" & $iSecs) ; Here you add that value to the total <<<<<<<<<<<<<<<<<<<<<<<<<< $TotalTimeArray[$foundAt][1] = $TotalTimeArray[$foundAt][1] + $TimeArray[$foundAt][1] ; And convert it <<<<<<<<<<<<<<<<<<< _TicksToTime($TotalTimeArray[$foundAt][1], $iHours, $iMins, $iSecs) ConsoleWrite(", Cumulative value = " & $TimeArray[$foundAt][1] & " which is " & $iHours & ":" & $iMins & ":" & $iSecs & @CRLF) ; And now reset ready for the next TimerInit <<<<<<<<<<<<<<<<<<<<<<<< $TimeArray[$foundAt][1] = 0 EndIfAny better? Not being able to run the script is a real problem - but I am trying my best. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
dragonlord Posted November 20, 2012 Author Share Posted November 20, 2012 I cant imagine how you'd be helping me out without beijng able to run it. (Needs MS Office communicator, which i'm sure you figured already ). Code doesnt seem to make a difference. Cumulative value still wrong. Almost at the verge of giving up .... resetting time to 0 for gil.ipe. Need to save previous ticks 1033644466944 which is 0:0:6, Cumulative value = 1033644466944 which is 287123:27:46 resetting time to 0 for gil.ipe. Need to save previous ticks 1033672880699 which is 0:0:10, Cumulative value = 1033672880699 which is 574254:49:7 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 21, 2012 Share Posted November 21, 2012 I cant imagine how you'd be helping me out without beijng able to run it. (Needs MS Office communicator, which i'm sure you figured already ). Which is why you should post a reproducer, not your actual script. A short, working, example script that demonstrates your problem/question. First it narrows down the problem which helps you to find the resolution yourself, but if you can't solve it, it's easier for others to help you also. Now it looks to me like you are adding to the return from TimerInit(), and that's just not going to work. The handle from TimerInit() is for TimerDiff() only. $TotalTimeArray[$foundAt][1] = $TotalTimeArray[$foundAt][1] + $TimeArray[$foundAt][1] $TimeArray is an array of TimerInit()'s, right? Big mess right there. Don't give up. I'm sure you can figure it out .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
kaotkbliss Posted November 21, 2012 Share Posted November 21, 2012 (edited) To further what Admiral was saying (and I'm going on memory) but I believe TimerInit uses some internal clock and does not start at 0. What TimerDiff does is take the value of when TimerInit started and subtract from the current value of TimerInit to give you the milliseconds that have passed between the TimerInit values. Example: $time = TimerInit();<<The internal clock's START time ;do some stuff $difference = TimerDiff($time);<<START time subtracted from Internal clock's CURRENT time so the time between start and current would be held in $difference Edited November 21, 2012 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
kylomas Posted November 21, 2012 Share Posted November 21, 2012 And you might accumulate time and express it like this local $st = timerinit() ; start first timed interval sleep(6000) local $intrvl1 = timerdiff($st) ; # of milli secs for 1st interval $st = timerinit() ; start second interval sleep(3000) local $intrvl2 = timerdiff($st) ; # of milli secs for 2nd interval local $duration = $intrvl1 + $intrvl2 ; accumulation of monitored time consolewrite('! Duration = ' & stringformat( '%02i:%02i:%02i', _ floor( ($duration/1000)/60^2), _ mod( ($duration/1000)/60,60 ), _ mod( ($duration/1000), 60 )) & @lf) (* - some of the code happily plagarized from BrewmanNH) kylomas 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 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 21, 2012 Share Posted November 21, 2012 To further what Admiral was saying (and I'm going on memory) but I believe TimerInit uses some internal clock and does not start at 0.What TimerDiff does is take the value of when TimerInit started and subtract from the current value of TimerInit to give you the milliseconds that have passed between the TimerInit values.It's a little more involved than that. Look at the source for _Timer_Diff(), it's basically the same.Posted from Nokia N900 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 21, 2012 Moderators Share Posted November 21, 2012 dragonlord,I cant imagine how you'd be helping me out without beijng able to run itWith that attitude you can be sure you will not be getting any more sugestions from me. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now