#139865 - 2005-05-18 12:02 AM
Comparing strings
|
kholm
Korg Regular
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
When comparing strings, shouldn't the longest string be greater than the shorter string ?
Example 1, comparing strings: Code:
If '5' > '45' '5 > 45' Else '45 > 5' EndIf
The result of this will be: 5 > 45
Example 2, comparing strings convertet to integer: Code:
If Val('5') > Val('45') '5 > 45' Else '45 > 5' EndIf
The result of this will be: 45 > 5
I'm using numbers because it is easyer to explain, but shuldn't 'ab' be greater than 'b'
-Erik
|
Top
|
|
|
|
#139868 - 2005-05-18 12:37 AM
Re: Comparing strings
|
kholm
Korg Regular
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
I don't believe it is an ASCII thing it is a KiX-string thing, my wish is that KiX treats strings as strings when comparing
Code:
If 'ab' > 'b' 'ab > b' Else 'b > ab' EndIf
Result is: b > ab
Get $x
|
Top
|
|
|
|
#139872 - 2005-05-19 12:32 AM
Re: Comparing strings
|
kholm
Korg Regular
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
Sorry for starting this tread (NOT)
It clarified my own view on the <> operators. Strings are treatet as a librarian would, and changing this could break existing scripts.
This is just another force of KiX, and you can code yourself out of the lenght-thing by using the Len() functionby ie. Code:
$O3 = '86' If Len($O3) = 3 And $O3 > '115' '115 > 86' EndIf
If i use above code '115' will be > '86'
If the Len() function wasn't used '86' would be greater than '115'
-Erik
ps. Can I close this now
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 557 anonymous users online.
|
|
|