Skip to content
⌘ NSIS Forum Archive

Select/Unselect a section, depending of existing file in install path

3 posts

Couin#

Select/Unselect a section, depending of existing file in install path

Hi friends 🙂

NSIS v2.51 (updating to more recent would force me to rewrite some code and from memory, some things was not running in v3.x).

Install (custom, related with this post) path page is displayed before Components page (sections).

I'm trying to select or unselect a section if a specific file exists in the install path (defined at the previous page).

I tried some diffferent codes but I still get the same "unknown variable/constant ${SecDemo} detected" at compilation 🙁

Here is a a part of code:

Function OnChange_Path
${NSD_GetText} $Path $Path_State
Call TestNewInst
FunctionEnd

!macro SECOFF Sec
SectionSetFlags ${Sec} 0
!macroend

!macro SECON Sec
SectionSetFlags ${Sec} 1
!macroend

Function TestNewInst
IfFileExists "$Path_State\file.ini" iniyes inino

iniyes:
MessageBox MB_ICONEXCLAMATION "Exists"
!insertmacro SECOFF "${SecDemo}"
Goto afterini

inino:
!insertmacro SECON "${SecDemo}"
Goto afterini

afterini:

FunctionEnd
How can I fix this error ?

Thanks 🙂
Anders#
The code that accesses SecDemo must come after the SecDemo Section in your .nsi You should be using the helper macros in sections.nsh to manipulate sections...