LOCNEWVALUE

The LOCNEWVALUE(v, x, a) built-in subroutine allocates space in a for the variable type described by the LOCATES attribute that is associated with x and assigns v to that area.

Read syntax diagramSkip visual syntax diagramLOCNEWVALUE( v, x,a)
v
Must be computational and scalar.
x
Must be an OFFSET reference with the LOCATES attribute. x must be scalar.
a
Must be an AREA reference. a must be scalar.

If you do not specify a, the OFFSET attribute for x must have specified an AREA reference, and LOCNEWSPACE allocates space in that area.

The following three statements are equivalent:
  • call locnewvalue(v, x, a);
  • call locnewspace(x, a);
  • locval(x) = v;
If the OFFSET attribute for x specifies an AREA attribute, the following statements are equivalent:
  • call locnewvalue(v, x);
  • call locnewspace(x);
  • locval(x) = v;
In the following code snippet, the two executable statements are equivalent: Both statements allocate 17 bytes in the pool area, assign that offset to name(1), and assign the ‘Sherlock Holmes’ value as a character varying string to that location in the area.
            declare
              1 data based(data_ptr) unaligned,
                 2 actual_count fixed bin(31),
                 2 orderinfo(order_count refer(actual_count)),
                    3 name    offset(pool) locates(char(30) varying),
                    3 address offset(pool) locates(char(62) varying),
                 2 pool area(10_000);

            call locnewvalue('Sherlock Holmes’, name(1));
            call locnewvalue(‘Sherlock Holmes’, name(1), pool);