Skip to main content

TYPE Structure Special Functions

LOAD

EXPORT LogicalType LOAD(PhysicalType alias) := expression;

LogicalTypeThe value type of the resulting output of the function.
PhysicalTypeThe value type of the input parameter to the function.
aliasThe name of the input to use in the expression.
expressionThe operation to perform on the input.

LOAD defines the callback function to be applied to the bytes of the record to create the data value to be used in the computation. This function defines how the system reads the data from disk.

STORE

EXPORT PhysicalType STORE(LogicalType alias) := expression;

PhysicalTypeThe value type of the resulting output of the function.
LogicalTypeThe value type of the input parameter to the function.
aliasThe name of the input to use in the expression.
expressionThe operation to perform on the input.

STORE defines the callback function to be applied to the computed value to store it within the record. This function defines how the system writes the data to disk.

PHYSICALLENGTH

EXPORT INTEGER PHYSICALLENGTH(type alias) := expression;

typeThe value type of the input parameter to the function.
aliasThe name of the input to use in the expression.
expressionThe operation to perform on the input.

PHYSICALLENGTH defines the callback function to determine the storage requirements of the logical format in the specified physical format. This function defines how many bytes the data occupies on disk.

MAXLENGTH

EXPORT INTEGER MAXLENGTH := expression;

expressionAn integer constant defining the maximum physical length of the data.

MAXLENGTH defines the callback function to determine the maximum physical length of variable-length data.

GETISVALID

EXPORT BOOLEAN GETISVALID(PhysicalType alias) := expression;

PhysicalTypeThe value type of the input parameter to the function.
aliasThe name of the input to use in the expression.
expressionThe operation to perform on the input.

GETISVALID defines the callback function to determine that data values are in the specified physical format.

Example:

EXPORT NeedC(INTEGER len) := TYPE
  EXPORT STRING LOAD(STRING S) := 'C' + S[1..len];
  EXPORT STRING STORE(STRING S) := S[2..len+1];
  EXPORT INTEGER PHYSICALLENGTH(STRING S) := len;
  EXPORT INTEGER MAXLENGTH(STRING S) := len;
  EXPORT BOOLEAN GETISVALID(STRING S) := S[1] <> 'C';
END;
          
// delimited string data type
EXPORT dstring(STRING del) := TYPE
  EXPORT INTEGER PHYSICALLENGTH(STRING s) :=
               Std.Str.Find(s,del)+length(del)-1;
  EXPORT STRING LOAD(STRING s) :=
               s[1..Std.Str.Find(s,del)-1];
  EXPORT STRING STORE(STRING s) := s + del;
END;

See Also: TYPE Structure