Using Data Type Suffixes

Data type suffixes are a way of identifying what data type a variable is. Each data type is represented by a different suffix character which is added to the end of a variable name. For instance, the character % represents the data type integer. Whenever a variable name has a % at the end of the name, you know the data type for that variable is integer.

When data type suffixes are used, the chance of creating a data type mismatch error is greatly decreased. (A data type mismatch error is a particularly annoying error all programmers run into at some point in time.) One case in point would be if you tried to add 1 to a variable named AGE. Earlier in your program, you had declared AGE as type string, but had forgotten that. When your program is executed, the statement AGE + 1 is executed, creating a data type mismatch error, and causing the program to abruptly end. However, if you had named the variable AGE$, ($ being the suffix for the string data type) you would not have forgotten that AGE$ was of type string, and the error could have been avoided.

Previously, the DIM statement was described as: Although there is nothing wrong with the statement, it can be enhanced using data type suffixes. The following statement accomplishes exactly the same thing as the DIM AGE as Integer statement above.
This new version of the DIM statement declares that the variable AGE is of type integer because the % character represents the integer data type. Below is a listing of all the data types available with their suffixes.

Data TypeSuffixStandard DeclarationSuffix Declaration
Integer%DIM Age As IntegerDIM Age%
Long&DIM Rad As LongDIM Rad&
Single!DIM Balance As SingleDIM Balance!
Double#DIM Amort As DoubleDIM Amort#
Currency@DIM Deposit As CurrencyDIM Deposit@
String$DIM LName As StringDIM LName$
VariantNO SUFFIX AVAILABLEDIM X As VariantDIM X

Show details for Example CodeExample Code


Click here to view the example.
         
LotusScript Technical Learning Center | Partners | Lotus Home