chachew Posted October 23, 2011 Share Posted October 23, 2011 (edited) I have an array that is populated from a ListView so the array changes size/values every 8 seconds. There is one column that i am wanting to change every time the 8 second loop runs and reads the ListView. The column i am wanting to change is column 0 of each row, it is a 24hr time. I am reading those columns, using the StringSplit to isolate the HOUR and convert it to 12hr format and then save that into a new variable. All this i have successfully done, with the exception of getting that new variable back into the existing array. Code snippits below: For $r = 0 To $iRow - 1 For $c = 0 To UBound($array, 2) - 1 ; Enter each and every column, $c, on the row, $r. $array[$r][$c] = ControlListView("CallStatus","",3,"GetText", $r, $c) Next Next For $row=0 To UBound($array,1) - 1 _TimeAdjust() Next Func _TimeAdjust() For $i = 0 to UBound ($array,1) - 1 $split=StringSplit($array[$row][0],":") If $split[1]> 12 Then $newTime=$split[1]-12 & ":" & $split[2] Next ;~MsgBox(0,"",$newTime) EndFunc So i am now needing to get $newTime back into the array, something like this.... $array[$newTime][0] for each row in the existing array. Any suggestions? Edited October 24, 2011 by chachew Link to comment Share on other sites More sharing options...
enaiman Posted October 23, 2011 Share Posted October 23, 2011 Try this way: Func _TimeAdjust() For $i = 0 to UBound ($array,1) - 1 $split=StringSplit($array[$row][0],":") If $split[1]> 12 Then $array[$row][0]=$split[1]-12 & ":" & $split[2] EndIf Next ;~MsgBox(0,"",$newTime) EndFunc SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
chachew Posted October 24, 2011 Author Share Posted October 24, 2011 Try this way: Func _TimeAdjust() For $i = 0 to UBound ($array,1) - 1 $split=StringSplit($array[$row][0],":") If $split[1]> 12 Then $array[$row][0]=$split[1]-12 & ":" & $split[2] EndIf Next ;~MsgBox(0,"",$newTime) EndFunc Worked perfectly enaiman, THANKS Link to comment Share on other sites More sharing options...
chachew Posted October 24, 2011 Author Share Posted October 24, 2011 One last question, i modified Func _TimeAdjust() slightly to add "am" and "pm" to the end of the string but i have a problem appending "am". Since the function subtracts 12 from the 24hr formatted numbers the function thinks that 3:00pm is in the "am" so it turns out as 3:00pmam What am i missing? Func _TimeAdjust() For $i = 0 to UBound($array,1) - 1 $split=StringSplit($array[$row][0],":") If $split[1]>= 12 Then $array[$row][0]=$split[1]-12 & ":" & $split[2] & "pm" Next If $array[$row][0] <> $array[$row][0] & "pm" Then $array[$row][0]&= "am" EndFunc Link to comment Share on other sites More sharing options...
enaiman Posted October 24, 2011 Share Posted October 24, 2011 Think a little bit about this: $array[$row][0] <> $array[$row][0] & "pm" .... SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) 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