Default conversions are provided for some C storage formats. When the data is stored in an external format for which ESL provides a default conversion, you can specify just a type and a size in the using clause, and ESL supplies the conversion routine automatically. The following table shows how you specify the using clause for each of these C storage formats:
C data type |
using clause |
signed 1-byte integer |
using integer size 1 |
signed 2-byte integer |
using integer size 2 |
signed 4-byte integer |
using integer size 4 |
4-byte float |
using float size 4 |
8-byte double |
using float size 8 |
null-terminated character array |
using string size N (where N includes the NULL) |
You can use a default conversion for a C signed integer with a size of one, two, or four bytes. ESL stores integers internally as four- byte signed integers, so the following two field definitions are equivalent, although the first is more efficient:
integer MyField
integer MyField using integer size 4
You can specify a default conversion for a C float with a size of four or eight bytes. ESL stores floats internally as eight-byte double floats, so the following two field definitions are equivalent. Again, the first field definition is more efficient.
float MyField
float MyField using float size 8
Only SBCS (Single-Byte Character Set) strings are supported within structure variables. A field in a structure may not contain a DBCS (Double-Byte Character Set) string.
For any C data type other than the types shown on the preceding page, you must specify external and the name of the DLL for your own external conversion routine in the using clause.
All ESL integers are signed, so ESL always treats the high-order bit of an integer as the sign rather than as part of the value. Therefore, you should not convert a C-language unsigned long into an ESL integer value. Convert it to a float, instead.