- NSIS Discussion
- Custom page checkbox {IF} logic
Archive: Custom page checkbox {IF} logic
wirelessjava
17th April 2006 12:13 UTC
Custom page checkbox {IF} logic
I have a checkbox on a custom page and am reading it in as so:
ReadINIStr $R1 $INI "Field 2" "State"
However I am having problems knowing what state the buton is in:
${If} ${SectionIsSelected} $R1
MessageBox MB_OK 'Radio selected'
I've tried it many ways.
What is the easiest way to detect true/false of a radio button?
Afrow UK
17th April 2006 14:08 UTC
SectionIsSelected is for NSIS Sections.
${If} $R1 = 1
MessageBox MB_OK 'Radio selected'
${EndIf}
-Stu
wirelessjava
17th April 2006 15:36 UTC
Ah, thank you.
It always seems to return 0 or the value of state when set, regardless of the radio box checked or not.
ini file:
[Field 4]
Type=RadioButton
Left=60
Right=-220
Top=50
Bottom=80
read in :
ReadINIStr $R4 $INI "Field 4" "State"
your new code:
${If} $R4 = 1
MessageBox MB_OK 'Radio selected'
${EndIf}
The message only appears if I change the if to 0 instead of 1.
any ideas?
Afrow UK
17th April 2006 16:58 UTC
Where is this code to read the value of the page?
It can't be directly after the InstallOptions call, but in the pages' Leave function.
-Stu
wirelessjava
17th April 2006 20:13 UTC
The ini read is in the LeaveCustom function that I added to the Custom page declaration.
The function seems to be called OK, as im able to get a string from another field i've added to $R1
The IF statement is in the middle of a Section which gets called ok as I can get the message box to popup if i set the condition to 0 instead of 1.
Afrow UK
17th April 2006 21:22 UTC
Please attach your script. There isn't any more I can do without it.
-Stu
wirelessjava
17th April 2006 23:06 UTC
Ok, thank you very much for taking the time.
It's basically a slightly modified Modern UI - HeaderBitmap example.
the testCustom ini :
[Settings]
NumFields=7
[Field 1]
Type=Label
Left=5
Right=-220
Top=10
Bottom=18
Text=Path :
[Field 2]
Type=DirRequest
Left=105
Right=-20
Top=8
Bottom=21
state=c:\temp\folder
[Field 3]
Type=Label
Left=5
Right=-250
Top=60
Bottom=80
Text=Visual Studio :
[Field 4]
Type=RadioButton
Left=60
Right=-220
Top=50
Bottom=80
[Field 5]
Type=Label
Left=110
Right=-150
Top=60
Bottom=80
Text=Dev C++ :
[Field 6]
Type=RadioButton
Left=155
Right=-50
Top=50
Bottom=80
[Field 7]
Type=GroupBox
Left=0
Right=-1
Top=45
Bottom=85
Text=" IDE "
Afrow UK
18th April 2006 09:41 UTC
Your script was quite a mess really.
You were extracting two copies of testCustom.ini; displaying the InstallOptions dialog from one and then reading values from another!
Also, no need to declare Var INI.
If you need constants, use !define.
-Stu
wirelessjava
18th April 2006 12:08 UTC
Wow, that's some level of support I must say. Quite amazing!
And again, thank you for your time in resolving my problem.