With lavishscript, is it possible to use preprocessor directives to determine if a file was included or ran directly?
I want to create scripts with conditional main() functions, such that main() would only get declared if the file was invoked directly as a script, as opposed to being included in another script.
#include or not #included?
Moderators: Lavish Software Team, Moderators
Code: Select all
#if ${Script.Name.Equal[myfile.iss]}
function main()
{
}
#endif

That didn't work.
I created a script called test2include.iss
Output was:
It seems, that preprocessors wont use datatypes ( ${} ) at all. I also tried to #define a constant, and compare that to another #defined constant, but wasn't able to do that either. It seems to only do numeric comparison (which, doesn't surprise me).
What I'd like, is to have something like:
But to my knowledge, there isn't a built-in define to do that. Or, is there? Documentation seemed sketchy.
I created a script called test2include.iss
Code: Select all
#define TESTER ALL
#if ${TESTER.Equal[ALL]}
#echo TEST TRUE
#else
#echo TEST FALSE
#endif
#if ${Script.Name.Equal[test2include.iss]}
function main()
{
echo Main Test TRUE
}
#else
function main()
{
echo Main Test FALSE
}
#endif
Code: Select all
C:\Program Files\InnerSpace\Scripts\test2include.iss(5): TEST FALSE
Main Test FALSE
What I'd like, is to have something like:
Code: Select all
#ifndef _INCLUDED_
function main()
...
#endif
The preprocessor DOES in fact process data sequences. The part that didnt work was it wasnt actually in the scope of the Script at that particular time. I fixed this today in build 3353.It seems, that preprocessors wont use datatypes ( ${} ) at all. I also tried to #define a constant, and compare that to another #defined constant, but wasn't able to do that either. It seems to only do numeric comparison (which, doesn't surprise me).
#if and such DO only do numeric comparisons, exactly the same way if, while, math.Calc, etc do it. But, you can use data sequences to compare strings too.