In PowerScript CHOOSE
statement doesn't compare "...equivalent numeric value...", it just compares objects as they are (in this case strings, without any further processing). "9" is greater than "0" as "999" is greater than "000" (you can try "11" is smaller than "2").
From PowerScript reference manual documentation for expressionlist
parameter in CASE
you can see TO
clause accepts just values, conversion is usually made from testexpression
type to expressionlist
type(s) and not vice-versa. It means that if you provide strings then it'll compare strings instead of numbers!
There is not an equivalent of CHOOSE
in C# and switch
statement can't be used like that (you can find it, for example, in VB.NET for Select statement). Workaround is to use if
instead:
string text = ls_char.ToString();
if (text == "_")
ls_char = "-";
else if (text >= "0" && text <= "9")
MessageBox.Show("Digit");
To compare numbers what you have to do is to provide numbers in CASE
blocks:
CHOOSE CASE long(ls_char)
CASE 0 TO 5
MESSAGEBOX("SMALLER")
CASE 6 TO 9
MESSAGEBOX("SMALL")
END CHOOSE
In this case ls_char (whatever is its type) is converted to a number and then compared to check if it's in requested range. Roughly in C# it's equivalent to this:
int number = Convert.ToInt32(ls_char);
if (number >= 0 && number <= 5)
MessageBox.Show("Smaller");
else if (number >= 6 && number <= 9)
MessageBox.Show("Small");