DMAKE


NCHAR

 

The DMAKE instruction allows dynamic creation of a DIM or NCHAR character string variable. This instruction is similar to the SMAKE instruction except that the buffer allocation for the DMAKE instruction is performed using the operating system's memory allocation functions. Buffer allocations for DMAKE do not reside in the same memory allocation as used for the PL/B program. Thus, dynamic DIM or NCHAR variables can be created and freed without impacting the memory allocation used for programs and the size of these variables are only limited by the operating system resources. The instruction uses the following format:

 

 

[label]

DMAKE

{dest}{sep}{size}

 

Where:

label

Optional. A Program Execution Label.

dest

Required. A previously defined DIM or NCHAR POINTER variable.

sep

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.

size

Required. A previously defined Numeric Variable, Expression, or decimal constant indicating the size of the variable to create.

Flags Affected: ZERO

Note the following:

  1. {dest} must be a DIM or NCHAR Pointer Definition. Otherwise, a compiler error occurs.

  2. The ZERO flag is set FALSE when the DIM variable is created successfully and TRUE when it cannot be created.

  3. Since the buffer allocation for a DMAKE instruction does not reside within the PL/B program memory space, the ROLLOUT instruction cannot be used in programs that contain a DMAKE instruction. A ROLLOUT instruction causes an untrapped error U49 to occur if a DMAKE variable is active when the ROLLOUT is executed.

  4. When a CHAIN or SHUTDOWN instruction is executed, all DMAKE buffer allocations are automatically freed.

  5. If a DMAKE instruction is executed for a {dest} pointer that already references a DIM or NCHAR variable, a DRELEASE instruction is executed before the DMAKE is executed.

  6. Two associated instructions named DFREE and DRELEASE free buffer allocations created by the DMAKE instruction.

  7. The DMAKE instruction only uses the DIM pointer that is specified by the {dest} label reference. Therefore, should the {dest} pointer be pointing to a second pointer, the DMAKE does not affect the second pointer.

 

 

See Also: Example Code, Character String Instructions

 



PL/B Language Reference DFREE DRELEASE