Search code examples
nsis

can we restrict the 'defined_value' value inside the if condition in NSIS


here I was trying to restrict the 'defined_value' value inside the if condition, But it is working as the global condition Can anybody help me out with this issue, how can I restrict the "define_value"

!include LogicLib.nsh
Var data

Function .oninit

      StrCpy $data "15"

FunctionEnd

Function display

        ${If} $data == '20'
              MessageBox MB_OK "test"
               !define defined_value "50"
        ${EndIf}
        
FunctionEnd

Section test

       Call display
       Detailprint "Updated value : ${defined_value}"
       
SectionEnd

Solution

  • You cannot mix and match defines with variables and ${If}.

    Defines can only be checked with !if.

    If something needs to be set based on something on the end-users system when the installer is running you have to use a $variable.

    Defines and !if are evaluated when the compiler is executed on your machine...