MEMSQUEEZE

MEMSQUEEZE fills a target buffer with the contents of a source buffer with all multiple occurrences of a specified character replaced by one. It returns a size_t value that indicates the number of bytes written to the target buffer.

Read syntax diagramSkip visual syntax diagram
>>-MEMSQUEEZE(p,m,q,n,z,-+---+-)-------------------------------><
                         '-i-'     

p
Specifies the address of the target buffer.
m
Specifies the length in bytes of the target buffer. It must have a computational type and is converted to type size_t.
q
Specifies the address of the source buffer.
n
Specifies the length in bytes of the source buffer. It must have a computational type and is converted to type size_t. It must be non-negative.
z
An expression that must have the type CHARACTER(1) NONVARYING.
i
An optional expression that must be computational and will be converted to size_t as necessary. If not specified, the default value for i is 1. If i < 1, default value of 1 is used.
The returned value depends on the address of the target buffer or the size of the target buffer:

Example

dcl s  char(20);
dcl t  char(20);
dcl cx fixed bin(31);
 
s  = '...abc....def...gh..';
cx = memsqueeze(sysnull(), 0, addr(s), stg(s), '.');
      /* cx = 12         */
cx = memsqueeze(addr(t), stg(t), addr(s), stg(s), '.');
      /* cx = 12         */
      /* t = '.abc.def.gh.' */
 





Published: 23 December 2018