Alien Data Types

TYPE Structure

TypeName := TYPE

functions;

END;

TypeNameThe name of the TYPE structure.
functionsFunction Attribute definitions. There are usually multiple functions.

The TYPE structure defines a series of functions that are implicitly invoked when the TypeName is subsequently used in a RECORD structure as a value type. Parameters may be passed to the TYPE structure Attribute which may then be used in any of the function definitions. To pass the parameters, simply append them to the TypeName used in the RECORD structure to define the value type for the field.

Alien data types (TYPE) should only be used when accessing external data files. It is much more efficient to use the native types for general processing. In particular, some optimizations to project and filter files remotely are not supported on alien datatypes.

A TYPE structure may only contain function definitions from the the list of available Special Functions (see TYPE Structure Special Functions).

Example:

STRING4 Rev(STRING4 S) := S[4] + S[3] + S[2] + S[1];
EXPORT ReverseString4 := TYPE
        EXPORT STRING4 LOAD(STRING4 S) := Rev(S);
        EXPORT STRING4 STORE(STRING4 S) := Rev(S);
END;
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;
END;
ScaleInt := TYPE
        EXPORT REAL LOAD(INTEGER4 I ) := I / 100;
        EXPORT INTEGER4 STORE(REAL R) := ROUND(R * 100);
END;
R := RECORD
     ReverseString4 F1;
        // Defines a field size of 4 bytes. When R.F1 is used, 
        // the ReverseString4.Load function is called passing 
        // in those four bytes and returning a string result.
     NeedC(5) F2;

        // Defines a field size of 5 bytes. When R.F2 is used, 
        // those 5 bytes are passed in to NeedC.Load (along with 
        // the length 5) and a 6 byte string is returned.
     ScaleInt F3;

        // Defines a field size of 4. When R.F3 is used, the 
        //  ScaleInt.Load function returns the number / 100.
END;

See Also: RECORD Structure, TYPE Structure Special Functions