MAINSAIL Language Manual, Section 32.68

previous   next   top   contents   index   framed top   this page unframed


32.68. $createClassDscr

Figure 32–68. $createClassDscr
POINTER($classDscr)
PROCEDURE   $createClassDscr
                        (
STRING className,fieldNames,
                            
fieldTypes;
                         
OPTIONAL BITS ctrlBits);

$createClassDscr creates a CLASS descriptor from the information given by the arguments, and returns a POINTER to it. This CLASS descriptor POINTER can be used to allocate dynamic records with $createRecord. The fields of the CLASS $classDscr are not documented. className is the name of the CLASS (the effect is undefined if it is not a valid MAINSAIL identifier), fieldNames is the field names separated by eols, and fieldTypes is the field data types separated by eols, just like the corresponding values returned by $classInfo; the effect is undefined if more than one eol occurs between values, or at the start or end of either STRING. className and fieldNames are converted to upper case before being stored in the CLASS descriptor. className and fieldNames may be the null STRING, but fieldTypes must consist of a valid sequence of data type codes. Possible errors are an invalid fieldType and too many fieldNames. If an error occurs, NULLPOINTER is returned and an error message is generated unless ctrlBits has the predefined bit errorOK set. errorOK is the only valid ctrlBits bit.

The CLASS descriptor of a POINTER is returned by $dscrPtr.

Example 32–69 shows how a new CLASS descriptor can be created. In this case, a new CLASS descriptor is created from an existing one by changing the first field to be of the INTEGER data type.

Example 32–69. Use of $createClassDscr
STRING              s;
POINTER($classDscrcd;
POINTER             p,q;
assume p points to the CLASS descriptor
$classInfo(p,className,fieldNames,fieldTypes);
read(fieldTypes,s); # discard first type code
cd := $createClassDscr(    # give it a different
    "
INTEGER" & className, # name to distinguish it
    
fieldNames,
        # 
assume that we know it has more than one field
    
cvs(integerCode) & eol & fieldTypes);
q := $createRecord(cd); # allocate record of new CLASS

Section 50.1 describes a version of $createClassDscr, $createClassDscrExtended, that allows you to create a wider variety of CLASS descriptors. However, $createClassDscrExtended is a temporary feature.


previous   next   top   contents   index   framed top   this page unframed

MAINSAIL Language Manual, Section 32.68