Open piisgaaf opened 2 months ago
I suppose we are just after a sensible error message and a clean crash here; after all, .clear
removes procedure definitions from earlier in the script.
If the procedure is in a .prc
file, then somehow it doesn't cause this memory issue (lines after .clear
inside the procedure are ignored; could be (ab)used as an "early return" from procedures).
LOOP.prc
:
#procedure LOOP()
.clear
#endprocedure
main.frm
:
#call LOOP
.end
Just to give some background on how I use this now. FORM is started with the -pipe option. An external application is sending commands to FORM. When one of the commands is the .clear
instruction then the FORM program terminates and the client is unable to send more commands.
An outline of the FORM program is:
#-
#setexternal `PIPE1_'
#message FORM started and waiting for input
#prompt READY
#procedure LOOP()
#fromexternal-
#call LOOP()
#endprocedure
#call LOOP()
.end
I also tried to put the #fromexternal
in an indefinite loop, but the .clear
statement ends the loop after which the FORM program reaches the .end
and terminates.
And you would like to send .clear
so that you can "reset" everything and send new instructions? The problem is that .clear
is also trying to erase procedure definitions. @tueda 's example works but not if you call LOOP
twice in a row; then it segfaults.
To be honest, I have never used .clear
in my own FORM scripts. I am not sure what the intended behaviour is here.
Hi, I also never used it before ;-) until this weekend ;-)
I have created a simple FORM kernel for use in jupyter notebooks. In a notebook I have 2 chapters. Both chapters share the same FORM setup file. After performing FORM statements in the first chapter, the second chapter starts with a .clear
statement to start fresh, without having to restart and reconnect to the FORM program.
As a workaround, I now just restart the FORM program. The solution with the clear statement would be a cleaner solution than to just restart it.
When form executes a .clear statement inside a procedure it crashes with the following output:
The minimal program that illustrates this: