Changing or retrieving a field’s data type at run time¶
The data type of a field can be retrieved at run time using the form:
field_id->datatype
Data types are defined in sculptor.h with prefix DT_. See Arithmetic data types for a list of these values.
The data type of b4, i4, n4, u4, b8, i8 and u8 fields can be interchanged:
field_id->datatype = value
The valid changes are:
b4 (DT_BINARY) to DT_INTEGER, DT_UNSIGNED or DT_NUMBER |
i4 (DT_INTEGER) to DT_BINARY, DT_UNSIGNED or DT_NUMBER |
n4 (DT_NUMBER) to DT_BINARY, DT_INTEGER, DT_UNSIGNED |
u4 (DT_UNSIGNED) to DT_BINARY, DT_INTEGER or DT_NUMBER |
b8 (DT_BINARY) to DT_INTEGER or DT_UNSIGNED |
i8 (DT_INTEGER) to DT_BINARY or DT_UNSIGNED |
u8 (DT_UNSIGNED) to DT_BINARY or DT_INTEGER |
All other changes are ignored. No attempt is made to convert the value in the field.
When a datatype is changed, the number of implied decimal places is reset to zero. For n4 fields only, the number of implied decimal places can then be set using:
field_id->impdp = number
One use of the above features would be to define an i4 field in a data dictionary and then change it at run time to a type not supported in the data dictionary file, such as n4.1 or n4.3. See Number (n) type fields.
Note: The i8, u8 are supported since Sculptor version 6.2.0.
RELATED TOPICS |