Hello,
I initially had the following idea;
Upon testing the above X is always 0 and this transpires to be because %LOOKUP is looking for an exact match, which makes sense.
The element positions are important, i.e. CDE need to be 1, ABC need to be 2 etc. so the only idea I come up with to get around this is the below, but I was wondering if anyone had a better idea? I'd love to be able to do the check in 1 line rather than 10+;
I has to be in fixed format I'm afraid, the program I'm changing was written in 1989 (older than me!) and I personally don't like mixing free and fixed.
I initially had the following idea;
Code:
D X S 2p 0 D Array S 3a Dim(10) C Move 'CDE' Array(1) C Move 'ABC' Array(2) C Move 'FGH' Array(3) C Move 'IJK' Array(4) C C Eval X = %LookUp('G' : Array) C C X DSPLY C SETON LR
The element positions are important, i.e. CDE need to be 1, ABC need to be 2 etc. so the only idea I come up with to get around this is the below, but I was wondering if anyone had a better idea? I'd love to be able to do the check in 1 line rather than 10+;
Code:
D X S 2p 0 D Z S 2p 0 D Found S 1a D Array S 3a Dim(4) C Move 'CDE' Array(1) C Move 'ABC' Array(2) C Move 'FGH' Array(3) C Move 'IJK' Array(4) C C Eval X = 0 C Eval Z = 0 C Eval Found = 'N' C C DoW X <= 4 and Found = 'N' C C Eval X = X + 1 C Eval Z = %SCAN('G':Array(X)) C C If Z <> 0 C Eval Found = 'Y' C Leave C Endif C C EndDo C C X Dsply C C SETON LR
I has to be in fixed format I'm afraid, the program I'm changing was written in 1989 (older than me!) and I personally don't like mixing free and fixed.
Comment