Archive: confusion with variables...


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


Both should be either $0 or $R0. $0 and $R0 are not the same variable.

Fixed, thanks.


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).


The return value is the value InstallOptions pushes on the stack. It's usually "success" but can be "back", "cancel" or "error" IIRC.


yep this i get but we need to manually remove it from the stack every time??


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.


aha, ok thought there was something special to be done with the return value. thanxs!


upsss, $R0 will still be valid out of the function?


Yes.


but i try to use it and instead of the value i get 'success'.


Then you stored the return value from the stack in $R0 too.


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


If you remove Push $R0 and replace Pop $R0 with Pop $R1 it will work fine.


ok now i understand! :-S