If you need the functionality of LOCATE, you need to call a subroutine,
period.
My own solution years ago was to write a generic LOCATESUB subroutine to
be called from I-descriptors.
In retrospect, I am not so sure that was a good idea because it is
complicated enough that I never remember it exactly and end up looking
it up. I have done several i-desc utility subroutines like that, but
LOCATESUB is the one I am unhappy about.
Using my subroutine, I'd end up with some variation on this theme:
01: I
02: RAISE( TRANS(FILE2,@ID['*',1,1], -1, 'X' ));
SUBR( '*LOCATESUB',@ID['*',4,1],@1,4,1,0,'');
IF @ > 0 THEN @1<9,@> ELSE '?????'
Of course, that's all on line 2.
TRANS arg3 = -1 means return the entire argument.
TRANS lowers all delimiters, so RAISE bumps them back up again.
Instead of RAISE, I could have just located on subval level.
LOCATESUB has arguments for att, val, subval, & locate-by;
LOCATESUB returns a negative number if, internally, its locate takes the
else clause. Hence, the IF @>0 test.
( Everyone knows that
@ID['*',4,1] == FIELD( @ID, '*', 4, 1 ) == FIELD(@ID,'*',4)
, right? )
So is LOCATESUB general utility worth it?
If so, you can have it.
If not, a specific subroutine for this I-descriptor is in order. It
might be more maintainable.
Chas. Stevenson
> From: Bob Woodward
[snip]
> FILE1 @ID = "01*11223344*W1*EA"
>
> FILE2 @ID = "11223344"
> <5> = "CS^SP^EA"
> <9> = "1^2^12"
>
> I'm needing to get "12" back to the I-DESC in FILE1, again,
> hopefully without having to resort to a called basic program.
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/