Page 1 of 1

#INCLUDED constant for @IF prepocessor

Posted: Tue Feb 02, 2021 11:51 am
by lazi
Larger scripts are of course easier to handle in separate scripts which can be joined together by @INCLUDE at runtime.

I would like to test and write the individual parts separated from the main scripts which @includes them.
So the include script has to be complete with for example a waitevent loop.

If the @IF preprocessor could know if the script runs as a main script or as an included part then some parts could be automatically ignored if it is included, and could contain parts that needs to be run the "include" script individually.

Of course I can make a script with the waitevent loop and etc. and @INCLUDE the include script, but with something like an #included constant the include script could be self hosted.

What do you think?

Re: #INCLUDED constant for @IF prepocessor

Posted: Tue Feb 02, 2021 10:57 pm
by lazi
Sorry this topic is created to wrong place. The correct would be Hollywood/Wishlist.

Re: #INCLUDED constant for @IF prepocessor

Posted: Sun Feb 07, 2021 9:13 pm
by airsoftsoftwair
lazi wrote: Tue Feb 02, 2021 11:51 am If the @IF preprocessor could know if the script runs as a main script or as an included part then some parts could be automatically ignored if it is included, and could contain parts that needs to be run the "include" script individually.
Hmm, maybe I'm not understanding everything here but couldn't you just set a constant that signals whether there's is a main script or not? i.e.

Code: Select all

; this is the main script
Const #MAINSCRIPT = 1
@INCLUDE "subscript.hws"

Code: Select all

; this is the subscript
@IF #MAINSCRIPT
...
@ELSE
...
@ENDIF