REMOVE is the fastest way I've found to do this. You must remember not
to re-assign or change the array while you are processing it. Assuming
the array is THAT, even a THAT = THAT will reset the array processing
pointer and give you grief.
The following code will break the array up into attributes.
LOOP
THIS = ''
LOOP
REMOVE PART FROM THAT SETTING MARK
THIS := PART
WHILE MARK GT 2 DO
THIS := CHAR(256-MARK)
REPEAT
GOSUB PROCESS.THIS
WHILE MARK DO
REPEAT
The penultimate line perhaps should be WHILE MARK GT 1 DO - I have never
seen the char(255) delimiter in a real situation, so it's never been an
issue.
The following code is what I used in the past. It's not quite so fast,
but it was always good enough. This is the mechanism I used to process
associated multivalues. In the 80's an invoice with lots of lines could
cause an excruciatingly long delay without this technique. From memory,
I saw this first in an article by Jim Cronin.
$OPTIONS INFORMATION
DIM PART(100)
MAXMATTR = DCOUNT(THAT,@AM)
MATPARSE PART FROM THAT, @AM
FOR ATTR = 1 TO MAXMATTR
HERE = REM(ATTR,100)
IF HERE THEN THIS = PART(HERE) ELSE
THIS = PART(100)
MATPARSE PART FROM PART(0), @AM
END
GOSUB PROCESS.THIS
NEXT ATTR
Note that the above method needs to be written differently if you use
PICK style (static dimensioned arrays) because there is no zeroth array
element.
$OPTIONS PICK
DIM PART(101)
MAXMATTR = DCOUNT(THAT,@AM)
MATPARSE PART FROM THAT, @AM
FOR ATTR = 1 TO MAXMATTR
HERE = REM(ATTR,100)
IF HERE THEN THIS = PART(HERE) ELSE
THIS = PART(100)
MATPARSE PART FROM PART(101), @AM
END
GOSUB PROCESS.THIS
NEXT ATTR
Lastly, I have a vague memory that somewhere I may have been forced to
use a temporary variable like this
TEMP = PART(101)
MATPARSE PART FROM TEMP, @AM
Regards, Keith
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/