Data Types

Navigation:  Appendices > Macro Language >

Data Types

Previous pageReturn to chapter overviewNext page

The Q++ Macro language is strongly typed. All variables and literals have a type, and every built-in function you use in Macros returns a value of a specific type.

 

The 3 data types are :

 

Boolean

Variables of this type have only 2 possible values : true or false.

Integer

Integer variables can take the value of any 32-bit number, which is the range from –2.147.483.648 to 2.147.483.647. Note that dates are treated as integers.

String

Variables of this type represent text. Note that any raw text used must be enclosed in single quotes (the code line sName=Olivier will cause a compiler message, while sName='Olivier' will compile fine).

 

 

A lot of the verifications performed by the compiler involve making sure that values of one data type are not assigned to another type. Q++ provides built-in functions to convert a value from one data type to another, when that is possible (eg. transforming the number 88 into the string '88').

 

Most beginning users of typed languages associate strong typing with nit-picking. A quick example will show how it is necessary to ensure unambiguous interpretation of your code.

Suppose the compiler allowed you to add numbers and strings, how should it perform this operation ?

 

The result of the string 'My age is ' and the number 37 would presumably be the string 'My age is 37'.

But what about if the first string had been '2001' ? What should the result have been ? The string '200137' or the number 2038 ?

 

See also : Type Conversion Functions.


Topic 108110 updated on 01-Nov-2016.
Topic URL: http://www.qppstudio.net/webhelp/index.html?datatypes.htm