View Full Version : If Statement
Potz
27th June 2006, 19:02
I was wondering how I set this up to not run the rest of the function when a check box is checked by using an if statement.
here is the way I have my code set up now. I know this dosen't work now but can someone tell me a way to get this to work this way... if not maybe another way.
ReadINIStr $3 "$PLUGINSDIR\ServerIP.ini" "Field 5" "State"
${If} $3 = 1
leave function
${EndIf}
Joost Verburg
27th June 2006, 19:16
There is a typo in your code, to compare two values you should use ==
Potz
27th June 2006, 19:20
Thanks, do you know why the leave function part isn't working? I have been using the HM NIS edit program and it dosen't seem to want to build because of that.
JasonFriday13
27th June 2006, 22:18
Use Call LeaveFunction. You cannot use spaces in a function name.
Potz
28th June 2006, 11:19
Ok thats fixed thanks. Now for some reason it is aborting the creation process.
It says Error: resolving install function "LeaveFunction" in function "serverIP"
Note: uninstall functions must begin with "un.", and install functions must not
Error - aborting creation process
I know it has something to do with the leavefunction but I am not sure what to do inorder to fix it.
galil
28th June 2006, 13:19
In order to call a function you must HAVE it...
Potz
28th June 2006, 13:23
ok maybe call is not what I need because I do not have a leavefunction. All I want to do is if the check box is checked I do not want to run the rewrite code.
here is my function
;IP address change------------------------------------
Function ServerIP
!insertmacro MUI_HEADER_TEXT "Server IP Address Change" "This is for Clients only, if this is a server you are installing on then place localhost in the text area."
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "ServerIP.ini"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ServerIP.ini"
ReadINIStr $3 "$PLUGINSDIR\ServerIP.ini" "Field 5" "State"
${If} $3 == 1
Call LeaveFunction
${EndIf}
ReadINIStr $0 "$PLUGINSDIR\ServerIP.ini" "Field 2" "State"
Push localhost ;text in line to replace
Push $0 ;replace with
Push 169
Push "$DESKTOP\dashboard.properties"
Call ReplaceOnLine
Push localhost ;text in line to replace
Push $0 ;replace with
Push 173
Push "$DESKTOP\dashboard.properties"
Call ReplaceOnLine
FunctionEnd
;------------------------------------------------------
JasonFriday13
28th June 2006, 22:48
One note: usually !insertmacro MUI_INSTALLOPTIONS_EXTRACT "Serverip.ini" is put in the .oninit function, so that the installer loads the page very quickly.
Fixed function:
;IP address change------------------------------------
Function ServerIP
!insertmacro MUI_HEADER_TEXT "Server IP Address Change" "This \
is for Clients only, if this is a server you are \
installing on then place localhost in the text area."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ServerIP.ini"
FunctionEnd
Function LeaveServerIP
ReadINIStr $3 "$PLUGINSDIR\ServerIP.ini" "Field 5" "State"
${If} $3 == 0
ReadINIStr $0 "$PLUGINSDIR\ServerIP.ini" "Field 2" "State"
Push localhost ;text in line to replace
Push $0 ;replace with
Push 169
Push "$DESKTOP\dashboard.properties"
Call ReplaceOnLine
Push localhost ;text in line to replace
Push $0 ;replace with
Push 173
Push "$DESKTOP\dashboard.properties"
Call ReplaceOnLine
${EndIf}
FunctionEnd
;----------------------------------------------------
Now for your custom page. Change it to:
Page custom ServerIP LeaveServerIP
That should fix it :).
Potz
29th June 2006, 13:31
Awesome it works now. Thanks :)
harishkothuri
18th March 2011, 08:59
Hi,
Need help in NSIS Scripting.. Actually i want to check some folders are existed in one specific path. I know how to test one folder with IfFileExists . but i want to check more than one folder..
Ex: IfFileExists "$INSTDIR\..\FolderName" one two #( here am checking 1 folder Name in #INSTDIR path .. like this i want to check more than one folder nd then only it has to jump)
one:
stmt1
stmt2
...
two:
stmts.
MSG
18th March 2011, 12:42
1: Your IfFileExists command is incorrect. You're checking if anything called 'foldername' exists, regardless of whether it's a file or a folder. You need to check for existence of 'foldername\*.*' instead.
2. Use logiclib to easily add conditions to your If statement:
${If} ${FileExists} "$INSTDIR\..\FolderName1\*.*"
${AndIf} ${FileExists} "$INSTDIR\..\FolderName2\*.*"
3. ...what on earth does "stmt" mean?
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.