contents   index   previous   next



Automatic type conversion

 

When a variable is used in a context where it makes sense to convert it to a different type, ScriptEase automatically converts the variable to the appropriate type. Such conversions most commonly happen with numbers and strings. For example:

 

"dog" + "house" == "doghouse"   // two strings are joined

"dog" + 4 ==  "dog4"            // a number is converted

4 + "4" == "44"                 // to a string

4 + 4 == 8                      // two numbers are added

23  "17" == 6                  // a string is converted

                                // to a number

 

Converting numbers to strings is fairly straightforward. However, when converting strings to numbers there are several limitations. While subtracting a string from a number or a number from a string converts the string to a number and subtracts the two, adding the two converts the number to a string and concatenates them. String always convert to a base 10 number and must not contain any characters other than digits. The string "110n" will not convert to a number, because the ScriptEase interpreter does not know what to make of the "n" character.

 

You can specify more stringent conversions by using the global methods, global.parseInt() and global.parseFloat() methods. Further, ScriptEase has many global functions to cast data as a specific type, functions that are not part of the ECMAScript standard. These functions are described in the section on global functions that are specific to ScriptEase.

 


Properties and methods of basic data types