Start of change

MEMSQUEEZE

Start of change

Start of changeMEMSQUEEZE 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.End of change

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.
Start of changeiEnd of change
Start of changeAn 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.End of change
The returned value depends on the address of the target buffer or the size of the target buffer:

Example

Start of change
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.' */
 
End of change
End of change
End of change