- NSIS Discussion
- User Input Prompt
Archive: User Input Prompt
ssurfer26
29th January 2002 22:48 UTC
User Input Prompt
Ok I know I've asked this question before but I want to do this without an ini file if all possible. What I want is a prompt for some user input so it will pass that variable to the shortcut link NSIS creates.
The variable below is $0, $1 and $2.
Example:
CreateShortCut "$SMPROGRAMS\test\test\test.lnk" "$INSTDIR\test.exe" "-ip$0 -port$1 -pass$2" "$INSTDIR\test.exe" 0
How can I prompt the user to enter in the info so it will pass to the shortcut?
Thanks,
Derek :igor:
Smile2Me
30th January 2002 09:59 UTC
Hi ssurfer26,
NSIS does not have possibilities for this. But maybe you can write a small exe that will be called from the script and asks for the user input, saves it to the registry, so that the installer scripts can access the user input again.
This is a possibility...
Good luck, greetz,
Hendri.
Smile2Me
30th January 2002 13:24 UTC
Maybe also possible: use NSIS extension dll like programming to access the stack and user variables. So create a small exe that requests for user input and sets eg $R9 to the given value.
But again: i'm not sure this is possible (maybe someone else can verify this one)
Good luck, Hendri.
kichik
30th January 2002 15:11 UTC
Or you can just use InstallOptions which is already included in the NSIS pacakage. :)
ssurfer26
30th January 2002 20:14 UTC
ok I think the InstallOptions will work. Just have to figure out how to implement it into my script. So question... How do I package both the installer and the dll/ini files together? Do I need 2 install packages then? One to extract all the temp files and then excute the real installer?
Thanks
Smile2Me
30th January 2002 21:04 UTC
Derek,
i understood you didn't want to use an ini...
Whatever, here's how you do it:
SetOutPath $TEMP
File InstOpts.dll
File myini.ini
Push $TEMP\myini.ini
CallInstDll $TEMP\InstOpts.dll dialog
; return can be 'cancel', 'back', or 'Ok'
; so check this and then use ReadIniStr
; to read the $TEMP\myini.ini.
; Do not forget to delete these files after
; completing setup.
You can put this code whereever you like, eg in .onNextPage (then you can ask for a RegCode before getting to install files) or in some section.
Good luck, greetz,
Hendri.
ssurfer26
30th January 2002 23:16 UTC
ok well I kind of have it working... This is the code I have for a section. Only a few small problems. It doesn't popup until the very end after it's created the shortcuts already. How can I get that to run before it creates the shortcuts etc?
Derek
Example Code:
; optional section
Section "Monitoring Server Shortcuts"
SetOutPath $TEMP
File test.ini
File InstallOptions.dll
Push $TEMP\test.ini
CallInstDLL $TEMP\InstallOptions.dll dialog
Pop $0
; ($0 would be "success" "cancel" "back" or some other value on error.
ReadINIStr $R0 $7 "Field 1" State
ReadINIStr $R1 $7 "Field 2" State
ReadINIStr $R2 $7 "Field 3" State
Delete $TEMP\test.ini
Delete $TEMP\InstallOptions.dll
CreateShortCut "$SMPROGRAMS\test\test.lnk" "$INSTDIR\test.exe" "-1$R0 -2$R1 -3$R2" "$INSTDIR\test.exe" 0
SectionEnd
Smile2Me
31st January 2002 09:34 UTC
In the code you've posted, it's not possible (i think) that the shortcut is created before asking for input.
If you want to get the information before getting to 'install', use .onNextPage to put your question between some pages of the installer. Take a look at RegCode (included) for an example on how to ask for a regcode before selecting a dir.
Good luck, Hendri.
Dizzy007
16th September 2002 13:04 UTC
Custom Pages ??
Hi to all!
i'm new in using NSIS and i've problems to understand the code of "regcodenew" :(
Can anyone explain the following line to me?
!insertmacro CustomPages 01AB2345 $R9 $R8 onCustomPage onPageEntry onPageExit
OK - custom pages .. but how does it work?
And which section is section 5 ??
What about the sections at the end of the code (Section 1 to 3) ?? Are this the sections "1=Installation Options,2=Installation Directory,3=Installing Files" where i have to put my onw code???
And ... Exch-Pop-Push ...
In the "Funktion onCustomPage" the first thing is
Exch $0
Why ?
Thanks for help a newbie!!
Dizzy
kichik
16th September 2002 13:34 UTC
!insertmacro CustomPages 01AB2345 $R9 $R8 onCustomPage onPageEntry onPageExit
This line inserts a macro into the script. A macro is a defined set of lines that you can insert into your script in any positions. This line inserts the CustomPages macro which helps you create custom pages with ease (
MultIni4 is its newer version). Open up CustomPages.nsh, there are a lot of explainations about this macro in there.
And which section is section 5 ??
What about the sections at the end of the code (Section 1 to 3) ?? Are this the sections "1=Installation Options,2=Installation Directory,3=Installing Files" where i have to put my onw code???
You are confusing sections and pages. The numbers there represent pages, not sections.
And ... Exch-Pop-Push ...
In the "Funktion onCustomPage" the first thing is
Exch $0
Why ?
NSIS scripting langauge isn't a high language like C and friends. You have to use the stack manually in NSIS. To give a function an parameter you have to push it to the stack. For the function to get this parameter it has to pop it from the stack. Exch just replaces the top stack element with the given variable ($0 in this case). This was done so $0's old value won't get deleted by a simple pop instruction.
Dizzy007
16th September 2002 16:22 UTC
Custom pages
Yes ... now i see a little bit clearer! :p
Now i've to test a little bit with the stack.
Thanks for your help! :up:
Dizzy