Which operator returns the results you expect depends on the results you expect... Are you dealing with a number, or a string? Compare these:
Code:
Message("03" = 3)
Message("03" eq 3)
The first line outputs 1 (TRUE), the second outputs 0 (FALSE). Which is correct? Both.
The first line is using a numeric comparison, so it coverts the "03" to the number 3, sees 3=3, and returns TRUE.
The second line is using a alphanumeric comparison, so it converts the 3 to "3", sees "03" eq "3", and returns FALSE.
EDIT:
This very much applies to the other comparison operators too... look at this:
Code:
Message(2 < 10)
Message(2 lt 10)
The first returns 1 (TRUE), as you would expect, since 2 is less than 10.
What you might not expect is that the second returns 0 (FALSE). This is because it gets converted to "2" lt "10", and it does the comparison character by character in the strings... "2" is greater than "1" in the character map, so the comparison is FALSE.
Yah these were the issues I had expected. U r right with the not comparing other numbers as true.
I hadn't meant to compare 1,2,3,4 values to True, I had really meant to evaluate 1,2,3,4 as True.
Code:
test=3
If (test)
message ("Is True")
EndIf
So i would expect this to work:
Code:
If (RegRead( "HKLM", "System\State\Hardware", "Headset" ))
Run ("\Program Files\Tools\ScreenOff.exe")
ElseIf (wndActive ("Start"))
PowerOff
Else
Run ("\Windows\Display Switch.lnk")
EndIf
And now that I am clear on True = 1, and I would expect this to be more exact (in this case):
Code:
If (RegRead( "HKLM", "System\State\Hardware", "Headset" ) = True)
Run ("\Program Files\Tools\ScreenOff.exe")
ElseIf (wndActive ("Start"))
PowerOff
Else
Run ("\Windows\Display Switch.lnk")
EndIf
Sometimes it is beneficial of course to treat numbers as numbers/booleans and strings as strings (of course).
It probly is simpler to first check on lowercase to lowercase. We can first see if this works for case where uper/lower doesnt apply, like file and directory names.
It probly is simpler to first check on lowercase to lowercase. We can first see if this works for case where uper/lower doesnt apply, like file and directory names.
Ah, that makes sense then, I just had the order wrong. Upper case is before lower case in the character map.
Okay, if I don't want to use the beta version, I don't have the BREAK command. So how could I change this to work...
ForEach key, value in iniKeys ( UserFolder\"sort.txt","array" )
If ( Key eq LastImage )
Y = True
Endif
If (Y)
ArrayImg[I] = (Key)
I = I + 1
If ( I = ImageCount + 1)
BREAK
EndIf
EndIf
EndForEach
Okay, if I don't want to use the beta version, I don't have the BREAK command. So how could I change this to work...
ForEach key, value in iniKeys ( UserFolder\"sort.txt","array" )
If ( Key eq LastImage )
Y = True
Endif
If (Y)
ArrayImg[I] = (Key)
I = I + 1
If ( I = ImageCount + 1)
BREAK
EndIf
EndIf
EndForEach
.........Thanks!
To be sure I understand. . .
You want to do foreach, but instead of doing all values in the sort.txt you want to stop once you reach a specific count or value?
This kind of has a feel of an ini file format where you would put data in categories and then you could do a foreach for that category only.
Recovering iPad users may still remember the multitasking function where you can swipe left or right to … more
XDA Developers was founded by developers, for developers. It is now a valuable resource for people who want to make the most of their mobile devices, from customizing the look and feel to adding new functionality. Are you a developer?