Basic-Macros in fbc 1.08

Forum for discussion about the documentation project.
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Basic-Macros in fbc 1.08

Post by coderJeff »

yeah... it's really very limited where it can be used, like might be better to just call it broken so no one gets their hopes up.

"ON ERROR goto LABEL" saves the address of the LABEL to jump to on error
"ERROR n" unconditionally jumps to LABEL

For it to work, need to stay within the same stack frame.
If "ERROR n" is called from a sub procedure it's likely going to be jumping to code from a different stack frame.

Even if using something like a setjmp/longjmp to handle the stack issues, destructors don't get called, or temporary memory not on stack doesn't get freed.

To make it work, it's a lot more to add behind the scenes. Or add exception handling, though the code-flow is a little different than ON ERROR/RESUME ...
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Basic-Macros in fbc 1.08

Post by jj2007 »

coderJeff wrote:Or add exception handling, though the code-flow is a little different than ON ERROR/RESUME ...
Something like Try/Catch/Finally?

Code: Select all

Try
	n=n/0
	Print "div failed, but you won't see this message because we implemented SEH"
Catch
	MsgBox 0, "div failed", "You will see this message only on error", MB_OK
Finally
	print "that was tough, now let's continue"
Post Reply