Replace Null Delimiters

This is not a function but an option which can be added to the Set, Read, and Enumerate values functions to simplify the handling of the REG_MULTI_SZ data type. Without this option, in order to parse a list of strings containing embedded null bytes, you need to overlay the string variable on an unformatted variable and then use substring referencing to locate the null bytes and access the substrings between the null bytes. When the REGOP_DELIMS flag is added to, say, REGOP_ENUMVALS, then the embedded nulls are replaced by CHR(128) characters. Such a list of strings can then be parsed with code similar to the following (excerpted from the sample program REGPTR) which lists the individual bin names available for a printer.

! enumerate next value . . .

xcall MIAMEX, MX_REGISTRY, REGOP_ENUMVALS + REGOP_DELIMS, HKEYNEW, SUBKEY, INDEX, TYPE, V$, STATUS

 

! if no error, and value is printBinNames and of REG_MULTI_SZ type, parse it out

If STATUS=0 and SUBKEY="printBinNames" and TYPE=REG_MULTI_SZ then

X = 1

Y = 1

do while Y > 0

Y = instr(X,V$,chr(128))

if Y > 0 THEN

   BIN$ = V$[X,Y-1]

   X = Y + 1

   Print "BIN Name = ";BIN$

endif

Loop

endif