Re: True/False statements with OBJECT variables
- Posted by Daniel Berstein <daber at PAIR.COM> Apr 27, 1998
- 644 views
>use this instead: >if not compare(a,b) then > puts(1,"YAY! CORRECT!") >else > puts(1,"BAD!") >end if > >compare() returns zero for objects that "are" equal to one another, >hence the need for the "not" in the comparison. Also a "trim" function is useful, specially if your are using a gets(0). Example: function RightTrim(sequence s) if length(s) = 0 then return s end if if s[length(s)] <= 32 then if length(s) > 1 then return RightTrim(s[1..length(s)-1]) else return "" end if else return s end if end function function LeftTrim(sequence s) if length(s) = 0 then return s end if if s[1] <= 32 then if length(s) > 1 then return LeftTrim(s[2..length(s)]) else return "" end if else return s end if end function function AllTrim(sequence s) return LeftTrim(RightTrim(s)) end function if not compare(AllTrim(a),AllTrim(b)) then puts(1,"YAY! CORRECT!") else puts(1,"BAD!") end if Regards, Daniel Berstein.