leave function
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2459 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
479c5e66bd
commit
0a2cb77684
2 changed files with 42 additions and 19 deletions
|
@ -423,7 +423,10 @@ FunctionEnd
|
|||
<p class="subheader">Call the DLL</p>
|
||||
<p class="text">You can call InstallOptions in a page function,
|
||||
check the <a href="..\..\Docs\Chapter3.html#3.5">NSIS documentation</a>
|
||||
for information about the page system.</p>
|
||||
for information about the page system. Example:</p>
|
||||
<pre class="margin">
|
||||
Page custom SetCustom ValidateCustom
|
||||
</pre>
|
||||
<p class="text">The InstallOptions DLL has three functions:</p>
|
||||
<ul>
|
||||
<li>dialog - Creates the dialog immidiately</li>
|
||||
|
@ -432,7 +435,7 @@ for information about the page system.</p>
|
|||
</ul>
|
||||
<p class="text">Usually, you only need to use the dialog function:</p>
|
||||
<pre class="margin">
|
||||
Function FunctionName ;FunctionName defined with Page command
|
||||
Function SetCustom ;FunctionName defined with Page command
|
||||
|
||||
;Display the Install Options dialog
|
||||
|
||||
|
@ -441,6 +444,27 @@ Function FunctionName ;FunctionName defined with Page command
|
|||
InstallOptions::dialog $PLUGINSDIR\test.ini
|
||||
Pop $R0
|
||||
|
||||
FunctionEnd
|
||||
</pre>
|
||||
<p class="subheader">Get the input</p>
|
||||
<p class="text">To get the input of the user, read the State
|
||||
value of a Field using ReadINIStr:</p>
|
||||
<pre class="margin">
|
||||
ReadINIStr $R0 "$PLUGINSDIR\test.ini" "Field 1" "State"
|
||||
</pre>
|
||||
<p class="subheader">Validate the input</p>
|
||||
<p class="text">If you want to validate the input on the page,
|
||||
for example, you want to check whether the user has filled in
|
||||
a textbox, use the leave function of the Page command and Abort
|
||||
when the validation has failed:</p>
|
||||
<pre class="margin">
|
||||
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
|
||||
</pre>
|
||||
<p class="subheader">Return value</p>
|
||||
|
@ -458,12 +482,6 @@ the example above).</p>
|
|||
<p class="text">If you want to check the user input immidiately,
|
||||
for example, to display a warning when the input is invalid, you
|
||||
should check whether the user has pressed the Back or Next button.</p>
|
||||
<p class="subheader">Get the output</p>
|
||||
<p class="text">In most cases, you will need the output from the INI File
|
||||
in a section. Get it using ReadINIStr:</p>
|
||||
<pre class="margin">
|
||||
ReadINIStr $R0 "$PLUGINSDIR\test.ini" "Field 1" "State"
|
||||
</pre>
|
||||
<p class="subheader">ReserveFile</p>
|
||||
<p class="text">It you are using BZIP2 compression and your .onInit and Page
|
||||
functions are not above all other sections/functions with File commands, use
|
||||
|
|
|
@ -21,7 +21,7 @@ ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
|
|||
ReserveFile "test.ini"
|
||||
|
||||
;Order of pages
|
||||
Page custom SetCustom VerifyCustom ": Testing InstallOptions" ;Custom page. InstallOptions gets called in SetCustom.
|
||||
Page custom SetCustom ValidateCustom ": Testing InstallOptions" ;Custom page. InstallOptions gets called in SetCustom.
|
||||
Page instfiles
|
||||
|
||||
Section "Components"
|
||||
|
@ -64,14 +64,19 @@ Function SetCustom
|
|||
|
||||
FunctionEnd
|
||||
|
||||
Function VerifyCustom
|
||||
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 2" "State"
|
||||
StrCmp ${TEMP1} 1 done
|
||||
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 3" "State"
|
||||
StrCmp ${TEMP1} 1 done
|
||||
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 4" "State"
|
||||
StrCmp ${TEMP1} 1 done
|
||||
MessageBox MB_ICONSTOP|MB_OK "You must select at least one install option!"
|
||||
Abort
|
||||
done:
|
||||
Function ValidateCustom
|
||||
|
||||
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 2" "State"
|
||||
StrCmp ${TEMP1} 1 done
|
||||
|
||||
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 3" "State"
|
||||
StrCmp ${TEMP1} 1 done
|
||||
|
||||
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 4" "State"
|
||||
StrCmp ${TEMP1} 1 done
|
||||
MessageBox MB_ICONEXCLAMATION|MB_OK "You must select at least one install option!"
|
||||
Abort
|
||||
|
||||
done:
|
||||
|
||||
FunctionEnd
|
Loading…
Add table
Add a link
Reference in a new issue