- NSIS Discussion
- Displaying $InstDir in a textbox
Archive: Displaying $InstDir in a textbox
bSecRes
19th July 2003 20:10 UTC
Displaying $InstDir in a textbox
Slashes get removed.
I wanted to display a custom page right before the InstFiles page (mostly because I wanted an Install button). I decided to use this page to review the users selections during the install. I have a multiline textbox and I try to do this:
!insermacro MUI_INSTALLOPTIONS_Write "readytoinstall.ini" "Field n" "State" "Directory To Install To:\r\n\t$InstDir\r\n\r\n" but the output in the textbox is
Directory To Install To:
C:Program FilesFolder Name
('C:' and 'Program Files' may not actually be the user selection obviously, I just used those in this example.)
I checked the $InstDir variable and it still has slashes before and after I use it here but they won't show up in the textbox. Ultimately, the program gets installed correctly.
Brummelchen
19th July 2003 20:22 UTC
your question is similar to mine:
http://forums.winamp.com/showthread....hreadid=142732
i also need to transfer $INSTDIR to the IO
pls help
bSecRes
19th July 2003 20:24 UTC
I had originally written my post as a reply to yours but then I wasn't sure what it was exactly you were trying for so I posted a new thread.
bSecRes
19th July 2003 21:08 UTC
My problems is solved here kind of:
http://forums.winamp.com/showthread....hreadid=135250
Later I escape the slashes in a CopyFiles thing and it doesn't work. I'll keep you all up to date on my progress.
Edit:
Guide to escaping things in NSIS
$$ is $
$\" is "
&& is &
\\ is \
The convention appears to be double everything except the quote because that means null? If some other character has a natural meaning in it's double form like the quote then it will need to be escaped with $\x x being the character with natural double meaning.
Afrow UK
19th July 2003 23:21 UTC
Use the ConvertBStoDBS function on the NSIS archive for placing paths in an IO page.
http://nsis.sourceforge.net/archive/...ances=0,11,122
-Stu
Brummelchen
19th July 2003 23:50 UTC
Does not work so far - or am i wrong with this?
[Field 7]
Type=DirRequest
Left=10
Right=300
Top=95
Bottom=108
State=$R0
bSecRes
19th July 2003 23:56 UTC
Brummelchen, according to Afrow, you would want to do something like this:
Push $R0
Call ConvertBStoDBS
Pop $R0
WriteINIStr "SomeFile.ini" "Field 7" "State" $R0
You cannot set the value of state to $R0 in a text editor and then, once the Field is processed, have the current value of $R0 appear there.
Afrow UK
20th July 2003 00:08 UTC
bSecRes is correct.
-Stu
Brummelchen
20th July 2003 00:11 UTC
no fortune :(
page custom selectsaveitems
Function .onInit
;Extract InstallOptions INI Files
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "menu01.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "menu02a.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "menu03a.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "menu02b.ini"
FunctionEnd
Function selectsaveitems
Push $INSTDIR
Call ConvertBStoDBS
Pop $R0
WriteINIStr "menu02a.ini" "Field 7" "State" $R0
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "menu02a.ini"
FunctionEnd
Afrow UK
20th July 2003 00:19 UTC
Should be:
Function .onInit
;Extract InstallOptions INI Files
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "menu01.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "menu02a.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "menu03a.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "menu02b.ini"
FunctionEnd
Function selectsaveitems
Push $INSTDIR
Call ConvertBStoDBS
Pop $R0
!insertmacro MUI_INSTALLOPTIONS_WRITE "menu02a.ini" "Field 7" "State" $R0
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "menu02a.ini"
FunctionEnd
Doing a
WriteINIStr "menu02a.ini" "Field 7" "State" $R0
will write it to C:\menu02a.ini, because you did not specify the file path.
With MUI_INSTALLOPTIONS_WRITE, the macro puts the file path in for you (which is $PLUGINSDIR\menu02a.ini)
-Stu
Brummelchen
20th July 2003 00:29 UTC
This works, thx.
But i dont need "ConvertBStoDBS" any longer - the directory is shown proper without.
But there is something strange - the content of this page is shown after a second intermission (blank page) - huh, thats Mcafee - if deactivated its fast. grmpf - operation must be inside RAM.
aha - IC - i put that line somewhere before (.oninit) - now it's fast again :D
Afrow UK
20th July 2003 00:34 UTC
The \\ \ problem must have been an old IO issue, and must have been fixed in latest (or a recent) CVS.
-Stu
bSecRes
20th July 2003 00:35 UTC
Still an IO issue, just not with DirRequest fields.
Brummelchen
20th July 2003 01:19 UTC
jep it is
i used your idea for a pre-install page and get no "\"
Afrow UK
20th July 2003 11:46 UTC
"\" becomes "" in labels.
"\" stays as "\" in anything else (text boxes, dirrequest etc)
-Stu
kichik
20th July 2003 12:25 UTC
It's not an issue, it's by design. It is this way so you can use line breaks in labels. The unfortunate side affect is the need to double every black slash when writing to labels.
Brummelchen
8th September 2003 03:52 UTC
i tried to use this function but i had a minor problem that i have to be compatible to my "version 1" which has a "\" at each path infomation
eg
c:\programs\
and not
c:\programs
ConvertBStoDBS has bug inside which converts
c:\programs\
to
c:\programs\c:\programs\
Not familiar with the code i wrote the following script which is not comfortable but which does it better.
maybe someone can use it...
Function ConvertBStoDBS2
Exch $R0 ;input string
Push $R1 ;length string
Push $R2 ;output string
Push $R3 ;temp string
Push $R4 ;counter
Strlen $R1 $R0
StrCmp $R1 "0" done
StrCpy $R2 ""
StrCpy $R4 "0"
loop:
StrCpy $R3 $R0 1 $R4
StrCmp $R3 "\" "0" nobs
StrCpy $R2 "$R2$R3"
nobs:
StrCpy $R2 "$R2$R3"
IntOp $R4 $R4 + 1
IntCmp $R4 $R1 loop loop "0"
StrCpy $R0 $R2
done:
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0 ;output string
FunctionEnd