Page 1 of 1

Strange REPEAT behaviour

Posted: Tue Jun 10, 2014 6:42 pm
by U
We are trying to create PAL code to remove comments from email addresses such as ROBERT(BOB).KATTER@NP.ORG.AU

Here is the code fragment involved.

Code: Select all

;---------------------------------------------------------------------------------
; Remove Comments
;---------------------------------------------------------------------------------

*\( | ** | \)
CONCAT " " temp
CONCAT [1] temp
COPY_S [2] guts
CONCAT guts temp
CONCAT [3] temp
CONCAT temp {Comment}
RETYPE [1] 0
RETYPE [2] 0
RETYPE [3] 0
REPEAT
With only one comment, as above, the code works well.
The residual is "ROBERT.KATTER@NP.ORG.AU" and Comment contains "(BOB)".

However, when the source data has more than one comment, there is duplication in the Comment field.
For example, from source "ROBERT(BOB).KATTER@NP.GOV.AU(FNQ)" the Comment field contains "(BOB) (BOB) (FNQ)".

From source "ROBERT(BOB).KATTER(THE HAT)@(FEDERAL)NP.ORG.AU(FNQ)" the Comment field contains "(BOB) (BOB) (THE HAT) (BOB) (THE HAT) (FEDERAL) (BOB) (THE HAT) (FEDERAL) (FNQ)".

What might be going on here? It appears that the RETYPE to null class actions are not being heeded, and the entire input is being scanned each time.

We have established that it is not permissible to use the form 0*\( | ** | \)

Thank you for your time.

Posted: Tue Jun 10, 2014 6:51 pm
by stuartjvnorton
You're not clearing out temp each time you hit a comment.

Try

COPY "" temp

prior to the initial

CONCAT " " temp

Posted: Tue Jun 10, 2014 7:52 pm
by ray.wurlod
Stuart beat me to it. You need to clear the temp variable.

Posted: Tue Jun 10, 2014 8:26 pm
by U
Thank you for your replies. As usual you were right "on the money".