FlexBASIC request: STOP
in Propeller 2
@ersmith Any chance of implementing STOP in FlexBASIC? I am longing for this feature for debugging. All it would need to do is stop further execution on the cog that calls it after printing a message like "STOP encountered in /module/routine/line" to the console. After that, it enters into an endless DO:LOOP. All other cogs would remain unaffected.
STOP encountered at line 534 in GPSLIB.BAS/GetWayPoint()
Maybe optionally pass it a message to print too?
STOP encountered at line 534 in GPSLIB.BAS/GetWayPoint() MSG: Too many waypoints
What thinks ye?
Comments
In C you could easily just define that as a macro. Not sure if the BASIC preprocessor is powerful enough.
I'm not aware that FlexBASIC "knows" about macros at all. But macros would be a cool capability now that you mention it...![:) :)](https://forums.parallax.com/resources/emoji/smile.png)
Infact, yes, you can create such a STOP command as a macro:
Well I’ll be a monkey’s step-uncle! I had no idea. Is this even in the docs? Gotta try this when I get home. Thanks @Wuerfel_21
The preprocessor is documented in the FlexBASIC manual, but the full implications (including that yes, things like @Wuerfel_21 's macro are possible) may not be immediately obvious.
I finally got home and was able to play with this. New toys! The only "gotcha" is anything defined by #DEFINE seems to be case sensitive, and the BASIC language by default is not. So:
will fail, but...
...works a treat. Thanks for the heads-up @Wuerfel_21 and @ersmith.
@JRoark Maybe then you could create two #DEFINES, one for "STOP" and one for "stop"...so you can use either
Don't Repeat Yourself...
Also, I just noticed the "slight problem" that
__LINE__
doesn't actually evaluate the line that the macro is instantiated on, but the line that it is defined on, I think that's a bug.Ouch! The LINE macro is being expanded at the wrong place. I'll have to look into that.