Problem encountered in the implementation of the 'cavity alignment' macro
A problem was encountered with the ALP program when calling the CAVITIES_LOCKING and CAVITIES_NLAC macros from the CAVITIES_ALIGNMENT parent macro (v1r4-Shared_Macros.cfg): when the macros were run individually they would execute without problems, but when called within an IF-ENDIF loop within the parent macro they would not run properly.
After a pretty long debugging time it was discovered that the problem was being caused by a strange behaviour in the IF-ENDIF loop of the parent macro. Summarised with the following example:
MACRO "PARENT_MACRO"
OP VAR1 = 1
IF VAR1 == 1
EXEC_MACRO MACRO1
...
ENDIF
...
ENDMACRO
MACRO "MACRO1"
OP VAR1=0
...
ENDMACRO
When MACRO1 is called from the parent macro it stops after the first lines without apparent reason and without providing information on why it has occurred. It was discovered that the variable 'VAR1' was being re-read by the parent macro within MACRO1 and was consequently ending the ENDIF loop. The problem was complicated by the fact that the loop was not ended immediately, but a few lines later.
The problem was resolved by moving the 'OP VAR1=0' command to the parent macro, after the EXEC_MACRO MACRO1 line. The modifies version is as follows:
MACRO "PARENT_MACRO"
OP VAR1 = 1
IF VAR1 == 1
EXEC_MACRO MACRO1
OP VAR1=0
...
ENDIF
...
ENDMACRO
MACRO "MACRO1"
...
ENDMACRO
It seems to be a bug in the ALP program that caused this event to occur.