Archive: Problems reading InstallOptions field


Problems reading InstallOptions field
On a custom MUI page, I am using a page leave function to validate the user input. My problem is that after doing the ReadINIStr function it always returns the default field value of "Text" rather than the newly entered data. I am using NSIS 2.08 and the INI file is not opened by any other application.

Here are the contents of my INI file (CompName.ini)
---------
[Settings]
FieldNum=2

[Field 1]
Type=Label
Text=New Computer Name
<Position info follows and has been omitted>

[Field 2]
Type=Text
State=Text
<Position info follows and has been omitted>
---------

Here is the custom page defnition:
page custom ComputerName VerifyInput

Here is the VerifyInput function:
----------
;This is the problematic validation function
Function VerifyInput
Push $R0
Push $R1

;******This is where my problem lies. Read newly entered
; Computer Name from custom page
ReadINIStr $R1 "CompName.ini" "Field 2" "State"
; Display debug MB with entered Computer Name
MessageBox MB_OK "Name Entered = $R1"
;MessageBox always displays "Name Entered = Text"

;Now vaildate user entry, always fails since $R1="Text"
;See attachment for details on CheckName.exe
ExecWait '"$INSTDIR\CheckName.exe" $R1' $R0
IntCmp $R0 1 goodname badname badname
goodname:
StrCpy $RENAME 1
Goto done1
badname:
MessageBox MB_ICONEXCLATMATION|MB_OK|MB_TOPMOST "Computer Name must adhere to corporate naming standards...."
Abort
done1:
Pop $R1
Pop $R0
FunctionEnd
---------------

The attachment contains additional relevant excerpts from the NSI file.

Can anyone provide any insight as to why "Field 2" always contains "Text"? This is my first custom MUI page, am I going about this the wrong way? Just for grins, I have tried the following items:

Replace the ReadINIStr statement with the following:
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "CompName.ini" "Field 2" "State"

Additionally, I added the NOTIFY flag to the field in the INI file (I know it is not suppose to work with TEXT fields, but I'm grasping at straws), again with no joy.

Any thoughts would be greatly appreciated. Thanks.


Is there any 'text' field as well? I haven't used a text box before but there might be a text field in the ini file. You could try reading the text field instead of the state field. Do you use HM NIS Edit to make your custom pages?


Yes, I used HM NIS Edit to create the INI file. Yes, you can set a Text field associated with the Text control, however I don't believe it really serves any purpose for the Text control. However, I did give you suggestion a try, reading from the control's Text field will return whatever it was used to initialize it. It does not however return the value entered into the field via the form. Thanks for the suggestions though.


I think I see your problem. Your install is reading the skeleton CompName.ini which is probably in the same folder as your main script file.

Your verify function should use this:

ReadIniStr $R1 '$PLUGINSDIR\CompName.ini' 'Field 2' 'State'


By reading just 'CompName.ini', you are reading from the current working directory (probably $EXEDIR in this case.)

Comperio,

Thanks, that did indeed fix the problem. I guess I failed to realize that there is more than one version of the INI file. Thanks again for the quick reply.