trids Posted March 26, 2004 Posted March 26, 2004 I can't seem to get the correct answer when comparing two numbers that originate from strings, but which must be compared numerically. Here's the function where the comparison is made expandcollapse popupFunc _Evaluate($pVal_1, $psComparator, $pVal_2, $psDataType) ;Compares the return value from the isql against the ;threshold in the INI file .. and returns a True(1) or False(0) ;based on the comparator in the INI file ;Default RC to False $RC = 0 if StringUpper($psDataType) = "NUM" then $pVal_1 = Number($pVal_1) $pVal_2 = Number($pVal_2) Else $pVal_1 = String($pVal_1) $pVal_2 = String($pVal_2) Endif _WriteLog ("Evaluating: " & $pVal_1 & " " & $psComparator & " " & $pVal_2) Select Case StringInstr( ":=:", ":" & $psComparator & ":") <> 0 If $pVal_1 = $pVal_2 Then $RC = 1 Case StringInstr( ":!=:<>:><:", ":" & $psComparator & ":") <> 0 If $pVal_1 <> $pVal_2 Then $RC = 1 Case StringInstr( ":>:", ":" & $psComparator & ":") <> 0 If $pVal_1 > $pVal_2 Then $RC = 1 Case StringInstr( ":<:", ":" & $psComparator & ":") <> 0 If $pVal_1 < $pVal_2 Then $RC = 1 Case StringInstr( ":>=:=>:", ":" & $psComparator & ":") <> 0 If $pVal_1 >= $pVal_2 Then $RC = 1 Case StringInstr( ":<=:=<:", ":" & $psComparator & ":") <> 0 If $pVal_1 <= $pVal_2 Then $RC = 1 EndSelect Return $RC EndFunc And here are the results 2004-03-26 (13:15:25) - Evaluating: 3 >= 25 2004-03-26 (13:15:25) - Evaluation returned TRUE: $ynResult = 1Any ideas how to make the comparison return False (0) for the above example?
Administrators Jon Posted March 26, 2004 Administrators Posted March 26, 2004 I ran that script with: MsgBox(0, "", _Evaluate("3", ">=", "25", "NUM")) And it returned 0 Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
trids Posted March 26, 2004 Author Posted March 26, 2004 When I run it like you did, I get the correct answer too .. I must have some cat by the tail - lemme go check my whole script again. Thanks again for the prompt replies, Jon
trids Posted March 26, 2004 Author Posted March 26, 2004 :blush: .. ok, turns out I was NOT sending "num" in $psDataType So the world is still round after all and I haven't fallen off .. yet! Thanks, and sorry for the false alarm! :iamstupid:
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