Page 1 of 1

Tip on using Strings - date, explicit, exclaimation

PostPosted: Thu Feb 07, 2002 4:18 pm
by Jim Brammer

Although this tip applies mainly for users who use my rtFileSystemMgt plug-in, it also applies in general to anyone who uses strings as a result.

One user posted this mail regarding the rtRightString command:

If the string contains a "+" sign, it will not be recognized

SetVar "[String]" "Amsterdam GMT +01"
SetVar "[rtInputVar1]" "[String]"
SetVar "[rtInputVar2]" "3"
SetVar "[X]" "[rtResult]"

The Result of X will be 1
Change the + sign in - (minus), the result of X will be -01


The rtRightString returns the correct result, i.e., '+01' as in above example. However, the actual problem was caused by the last statement:

SetVar "[X]" "[rtResult]"

NeoBook translate '+01' as a mathematical/integer value which means '+' is actually treated as an 'addition' and '01' is treated as a number.. and the '0' in '01' is truncated to '1' which explained why [X] variable is '1'.

To resolve the problem, add an additional '!' (exclaimation mark) to the [rtResult], i.e.

SetVar "[X]" "![rtResult]"

This will tell NeoBook that the value is a string.. and not an integer..

By doing so... [X] is now '+01' as it should be.

So, whether you're using rtFileSystemMgt or not.. remember to use '!' if you wish to indicate it as a string.
For example if you want to put a date,

SetVar "[X]" "12/25/01"

is not the same as

SetVar "[X]" "!12/25/01"

The first statement will return '0.48' while the second statement will return '12/25/01' as a string.

Hope this tip is useful to all...