This seemed like an interesting problem and I wanted to see if PC-Pipes
could solve it. This is what I came up with:

/* Globalv.rex */

address rxpipe

1  ‘pipe (name Globalv end ?)’,
2   '|literal group',           
3   '|spec /group/ 1.8 x04 n /var1/ n x05 n /value/ n',
4   '|dup 4',
5   '|substring 9-*',          
6   '|p:parcel',                   
7   '|d:deal',                     
8   '|copy',
9   '|spec 1.1 c2d 1',
10   '|fo:fanout',
11 '? literal 1',                   
12   '|fn:fanin',
13   '|p:',
14 '? fo:|copy|insert / 1/ after |fn:', 
15 '? d:', 
16   '|join 1 / /',
       '|cons'

The interesting parts are the parcel and deal stages.  
The secondary input to parcel is the following set of records:
                                 1
                                 nn 1
                                 nn 1
                                 ....
The first record is just the number 1. This causes parcel to extract
the one byte length of the first field of the first record.
The following records consist of the one byte field length converted to decimal
followed by a 1 for the next one byte field length. Thus parcel outputs
the one byte field length followed by the field value.

The deal stage sends the first record, the one byte field length, to its 
primary output 
to be converted to decimal and then send back to the parcel stage secondary 
input.
The second record, the field value, is sent to the secondary output. It repeats 
this 
for each pair of records.

James Johnson

Reply via email to