Old 19th July 2003, 19:10   #1
bSecRes
Junior Member
 
Join Date: Jul 2003
Location: LA USA
Posts: 37
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.
bSecRes is offline   Reply With Quote
Old 19th July 2003, 19:22   #2
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
your question is similar to mine:
http://forums.winamp.com/showthread....hreadid=142732

i also need to transfer $INSTDIR to the IO

pls help

Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 19th July 2003, 19:24   #3
bSecRes
Junior Member
 
Join Date: Jul 2003
Location: LA USA
Posts: 37
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 is offline   Reply With Quote
Old 19th July 2003, 20:08   #4
bSecRes
Junior Member
 
Join Date: Jul 2003
Location: LA USA
Posts: 37
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.

Last edited by bSecRes; 19th July 2003 at 20:29.
bSecRes is offline   Reply With Quote
Old 19th July 2003, 22:21   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 19th July 2003, 22:50   #6
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
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

Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 19th July 2003, 22:56   #7
bSecRes
Junior Member
 
Join Date: Jul 2003
Location: LA USA
Posts: 37
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.
bSecRes is offline   Reply With Quote
Old 19th July 2003, 23:08   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
bSecRes is correct.

-Stu
Afrow UK is offline   Reply With Quote
Old 19th July 2003, 23:11   #9
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
no fortune

code:

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


Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 19th July 2003, 23:19   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Should be:
code:
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
Afrow UK is offline   Reply With Quote
Old 19th July 2003, 23:29   #11
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
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

Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 19th July 2003, 23:34   #12
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
The \\ \ problem must have been an old IO issue, and must have been fixed in latest (or a recent) CVS.

-Stu
Afrow UK is offline   Reply With Quote
Old 19th July 2003, 23:35   #13
bSecRes
Junior Member
 
Join Date: Jul 2003
Location: LA USA
Posts: 37
Still an IO issue, just not with DirRequest fields.
bSecRes is offline   Reply With Quote
Old 20th July 2003, 00:19   #14
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
jep it is
i used your idea for a pre-install page and get no "\"

Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 20th July 2003, 10:46   #15
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
"\" becomes "" in labels.
"\" stays as "\" in anything else (text boxes, dirrequest etc)

-Stu
Afrow UK is offline   Reply With Quote
Old 20th July 2003, 11:25   #16
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 8th September 2003, 02:52   #17
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
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...

code:

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


Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump