Skip to content
⌘ NSIS Forum Archive

User input inside text file?

4 posts

Das123#

User input inside text file?

Hello,

I want to use NSIS to build an installer for email stationery for a large company. I want the people within the company to be able to run the installer, fill in a few boxes (name, title, mobile etc) and then have NSIS insert this information inside the HTML file in the relevant places.

I would also like the script to check to see if they have filled in a box, and if not to remove the html line for that portion (such as if they don't have a title).

So on my dialog page I need something like:

Enter your name: [input name]
Enter your title: [input title]
Enter your mobile number: [input mobile]

Hope someone can help me.
Das123#
Lol!

I actually have most of the script but I don't know how to effectively use dialog boxes.

The process I was going to use was to load the raw script onto the drive and then have a custom page at the end that edits the loaded html file. The html file was going to have a comment in the relevant places. Eg. <!-- name -->

Function writeOutput
    StrCpy $STRTOFIND "<!-- Name -->"
    StrCpy $STRTOREPL "<strong>Person's name</strong>"
    ${LineFind} "$INSTDIR\stationery.html" "$INSTDIR\stationery.html" "1:-1" "LineFindCallback"
    IfErrors 0 +2
        MessageBox MB_OK|MB_ICONEXCLAMATION "The file cannot be found and so will not be updated."
        
FunctionEnd
Function LineFindCallback
    
    StrLen $0 "$STRTOFIND"
    StrCpy $1 "$R9" $0
    StrCmp $1 "$STRTOFIND" 0 End
    StrCpy $R9 "$STRTOREPL$\r$\n"
    End:
    Push $0
FunctionEnd