Sign in to follow this  
Followers 0
trids

Datatype Errors

4 posts in this topic

B) 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

Func _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 = 1

Any ideas how to make the comparison return False (0) for the above example? :whistle:

Share this post


Link to post
Share on other sites



B) 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 :whistle:

Share this post


Link to post
Share on other sites

:blush: .. ok, turns out I was NOT sending "num" in $psDataType :whistle:

So the world is still round after all and I haven't fallen off .. yet! B)

Thanks, and sorry for the false alarm! :iamstupid:

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0