However, the ease of conversion between data types can be easily misunderstood. For example, a string like "yes" will freely convert to a Logical data type with value TRUE. An expression like Or("1","2") expects these two arguments "1" and "2" to be Logical types and first converts to give whole numbers 1 and 2, then converts onward to give TRUE,TRUE (because 0 converts to FALSE and nonzero values convert to TRUE). So it calculates Or(TRUE,TRUE) giving the answer TRUE. This is not a bitwise Or operator, but a Boolean or LOGICAL operator.
Another area which can cause extra work by the expression evaluator if not understood correctly is the construction of Lookup Tables (qlt's). Do not unnecessarily quote numbers or other constants. Quoting a number will just make the expression evaluator do extra work. For example, "1.2345" will be evaluated giving the number 1.2345 and quoting "Yes" and "No" will evaluate to the constants Yes or TRUE and No or FALSE. (Usually not harmful but wasteful, might as well write TRUE or Yes etc. in the first place.)
Note that:-
The following is a listing of the available data types in alphabetical order. Each of these data types can also be specified as a value.
The values can be used as a number (eg 3 or 5 etc) or you can directly specify the value as a string (eg "TYPE_WHOLENUMBER" or "MONEY"). Variables in the middleware always have some type (eg $5.20 is TYPE_MONEY and 150sqmm is TYPE_AREA).
You will notice that most types are closely related to the Units of a value, eg any value that ends in an angle unit (degrees or radians) is automatically set to be of type Angle.Data Type | Description |
---|---|
Angle | Used for any value with angle units (deg or rad) |
Area | Any value with area units (eg sqcm) or two multiplied length units (eg 3.4m x 94cm) |
Array | A value enclosed in square brackets (see the Arrays tutorial) or created by an Array function |
Color | Another way is to use the predefined constants (like BLACK RED CYAN etc) listed in the Constants section |
Date and Time | A full date such as the value of the built-in property Create_DTM (drawing creation date) |
Length | Any value with length units (eg metre, inch, etc) |
Lookup Table | The filename of a Lookup Table |
Map | A sequence of key : value pairs, where key is a string and value is any type. The sequence is comma separated and wrapped in curly brackets. (see the Maps tutorial) |
Money | Any value with money units (dollars or cents) |
Number | A numerical value, including decimal places |
Point2D | A pair of lengths, in brackets, comma separated, representing a point in the xy plane. Starts with Point2D. Example: Point2D(3mm,4mm) |
Point3D | Three lengths, in brackets, comma separated, representing a point in the xyz plane. Starts with Point3D. Example: Point3D(3mm,4mm,5mm) |
Rate | A value where there are multiple units combined, eg $67/hour or 1.4min/sqm; where you would use the word "per" |
String | Any text value, including text representations of other data types |
Time | Any value with time units (hour, second, minute) |
Volume | Any value with volume units (eg cbft) or an area multiplied by a length |
Whole Number | A numerical value which does not include decimals/fractions |
Yes or No | A boolean value, ie has only two possible values, regardless of what you call them: yes/no, on/off, true/false, or 1/0 |
TypeIndex | TypeName | TypeName as string |
---|---|---|
0 | TYPE_NONE | "<none>" |
1 | TYPE_STRING | "String" |
2 | TYPE_YESORNO | "Yes or No" |
3 | TYPE_WHOLENUMBER | "Whole Number" |
4 | TYPE_NUMBER | "Number" |
5 | TYPE_MONEY | "Money" |
6 | TYPE_TIME | "Time" |
7 | TYPE_LENGTH | "Length" |
8 | TYPE_AREA | "Area" |
9 | TYPE_ANGLE | "Angle" |
10 | TYPE_ARRAY | "Array" |
11 | TYPE_LOOKUPTABLE | "Lookup Table" |
12 | TYPE_DATEANDTIME | "Date and Time" |
13 | TYPE_VOLUME | "Volume" |
14 | TYPE_RATE | "Rate" |
15 | TYPE_COLOR | "Color" |
16 | TYPE_MAP | "Map" |
17 | TYPE_POINT2D | "Point 2D" |
19 | TYPE_POINT3D | "Point 3D" |