Archive: Mixing compile and runtime tests


Mixing compile and runtime tests
I am writing an nsh file whose behavior I would like to control based on the presence or absence of an ENV. For example, if the ENV exists, don't display the license page.

I can detect the presence or absence of the ENV at runtime, say in .onInit. But I have been unable to figure how to use this to control the display of windows since they are compiled in before execution. I've tried using !ifdef based on .onInit code but !ifdef uses values based on compile time.

Is this even possible? I'm suspecting not but would like to hear from someone more knowledgeable.


Use the 'pre' function of the License page to check the env variable (or one you set during .onInit) and Abort the page. This will go on to the following page and the user will never see the License page.

MUI_PAGE_WELCOME
MUI_PAGE_CUSTOMFUNCTION_PRE License.Pre
MUI_PAGE_LICENSE textfile
MUI_PAGE_COMPONENTS
...
function License.Pre
${If} $myVar = 1
Abort
${EndIf}
functionEnd

abcdgoldfish, do you mean you want to check whether or not the variable has been declared? I don't think there's a command for this. You should probably add a !define VarIsDeclared to the code that declares the var, and then use !ifdef VarIsDeclared in your header file.

Of course, this is only for controlling compile-time behaviour. If you want to change runtime behaviour, such as hiding the license page, then the solution above is what you should do.