- NSIS Discussion
- confusion with variables...
Archive: confusion with variables...
almoes
28th May 2004 14:42 UTC
confusion with variables...
Hi all!
I am a bit confused with the following function included in the InstallOptions docu:
Function ValidateCustom
ReadINIStr $R0 "$PLUGINSDIR\test.ini" "Field 1" "State"
StrCmp $0 "" 0 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter your name."
Abort
FunctionEnd
Isn't the value stored in $R0? so then why do you compare $0? thanxs!
cheers,
alej
kichik
28th May 2004 14:53 UTC
Both should be either $0 or $R0. $0 and $R0 are not the same variable.
Fixed, thanks.
almoes
28th May 2004 14:56 UTC
Ok i was getting a bit confused....another thing regarding this example, what does it mean the following from the 'return value' paragraph?
Usually, you don't need to check this value, but you still have to remove it from the stack (have a look at the example above).
kichik
28th May 2004 14:58 UTC
The return value is the value InstallOptions pushes on the stack. It's usually "success" but can be "back", "cancel" or "error" IIRC.
almoes
28th May 2004 14:59 UTC
yep this i get but we need to manually remove it from the stack every time??
kichik
28th May 2004 15:01 UTC
That refers to the usage of Pop which gets the top item on the stack and removes it. As mentioned in the documentation, the example shows it. The examples outside of the documentation show this too.
almoes
28th May 2004 15:04 UTC
aha, ok thought there was something special to be done with the return value. thanxs!
almoes
1st June 2004 14:52 UTC
upsss, $R0 will still be valid out of the function?
Joost Verburg
1st June 2004 16:23 UTC
Yes.
almoes
1st June 2004 16:37 UTC
but i try to use it and instead of the value i get 'success'.
Joost Verburg
1st June 2004 16:58 UTC
Then you stored the return value from the stack in $R0 too.
almoes
1st June 2004 17:00 UTC
and how do i know that?
here is my code:
Function SetParams ;FunctionName defined with Page command
InitPluginsDir
File /oname=$PLUGINSDIR\params.ini params.ini
;Display the Install Options dialog
Push $R0
InstallOptions::dialog $PLUGINSDIR\params.ini
Pop $R0
FunctionEnd
Function ValidateParams
ReadINIStr $R0 "$PLUGINSDIR\params.ini" "Field 2" "State"
MessageBox MB_ICONEXCLAMATION|MB_OK $R0
StrCmp $R0 "" 0 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter an address."
Abort
FunctionEnd
Joost Verburg
1st June 2004 17:13 UTC
If you remove Push $R0 and replace Pop $R0 with Pop $R1 it will work fine.
almoes
1st June 2004 17:31 UTC
ok now i understand! :-S