I just sat down to write a postprocessor for REXXVARS TOLOAD to fill in
a specified delimiter, and found out why I hadn't done it back when I
asked about this before.  AUTOFIELD is the way to pull out the variable
name, but there's a complication because the value may include the field
delimiter.  Long ago, I wrote:

> But Rob's got the right answer:  AUTOFIELD, which looks at the first
> character of the record for the field separator.
...
>   pipe literal *1*2*3*|specs autofield -2;-1|cons
>   2*3*

Turned out this was a bug that had just been fixed, and the last
AUTOFIELD no longer includes the trailing delimiter:

  pipe literal *1*2*3*|specs autofield -2;-1|cons
  2*3

I could copy the delimiter to the end of the record and then let
AUTOFIELD 2-* drop it--but not if I want to tolerate older pipeline
levels.  Since I know the variable name will never be null, in this case
I can copy the first *two* characters to the end and then drop the last
field:

  ... | specs 1-* 1 1.2 n | specs ... autofield 2;-2 ...

In cases where the field might be null, I could produce another record
with just the first field and modified separators, and then combine them:

  ... | specs "=" 1 af 1 2 "=" n write 1-* 1 | combine 1 first | ...

Am I overlooking a more straightforward, general approach?

I could *almost* avoid the whole issue here by not using TOLOAD, and
processing the records in pairs.  But I don't want to use the specified
delimiter when it occurs in the variable name, so I'd have to produce my
own delimiter in that case.

¬R

Reply via email to