Howards solution will work.

Your problem is the substring. The resultant data is of type "string", and when you do your comparisons the numeric data is also converted to a string so you get a string comparison.

You could have re-ordered your comparison to force a cast to integer type like so:
code:
If(39>=$RASsub AND 1<=$RASsub)
...
EndIf

This would also have worked.

However, explicity casting (or coercing) the type is far more readable.

{EDIT}
Hmmm. After re-reading I may have been looking at a more subtle problem than is present.
{/EDIT}

[ 27. May 2003, 16:44: Message edited by: Richard H. ]