Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Mui_page_directory (http://forums.winamp.com/showthread.php?t=269539)

AstraS 14th April 2007 13:34

Mui_page_directory
 
I have a problems.

1. in my installer i setup my files and Firebird.
First i use ExecWait tu setup firebird. After then i show
MUI_PAGE_DIRECTORY and add path of Firebird there.
PHP Code:

  !insertmacro MUI_PAGE_INSTFILES
  
!define MUI_DIRECTORYPAGE_VARIABLE $test_val
  
!insertmacro MUI_PAGE_DIRECTORY
  
!insertmacro MUI_PAGE_FINISH
..................some code cut..........................

Section "Main Section" SecMain

.............some code cut.....................
  
  
ReadRegStr $test_val HKLM "Software\Firebird  Project\Firebird Server\Instances""DefaultInstance"
  
StrCmp $test_val "" "" +2
         StrCpy $test_val 
"C:\Program Files\Firebird\"
  StrCpy $1 
$test_val

  StrCpy $2 "
Data\"
  StrCpy "
$test_val" "$1$2"

  SetOutPath "
$test_val"
  
  File "
B2.FDB"
SectionEnd 

this code serching path of Firebird and write it into Directory page path field.
When user change path in this field installer copy file not in new path, it use old path ($test_val).

2. How can i change value (space required) on directory page ?
Thanks!

kichik 14th April 2007 13:44

Sections are executed in the INSTFILES page. Therefore, whatever changes you make to $test_val after the INSTFILES page will not affect anything run in sections.

AstraS 14th April 2007 14:53

thx very mach!
and what to do?
how about number 2 question?

kichik 14th April 2007 14:58

That's a sum of the size required by each selected section. To change the size required by a section, use AddSize or SectionSetSize on runtime.

AstraS 14th April 2007 15:14

thx again.
and how use 2 directory page? show different path in each of them, and different free space requirement and diferent files install?
thanks!

AstraS 14th April 2007 15:16

PS and how connect 1 section to 1 directory page?
sorry for so many questions

kichik 14th April 2007 15:35

To show a different path, use MUI_DIRECTORYPAGE_VARIABLE as you already have and modify that variable so it's different than $INSTDIR.

To handle the required space, you must unselect all of the sections you don't want installed before showing the directory page. This way, their size won't be in the sum and they won't be executed. See the following example.

http://nsis.sourceforge.net/Two_inst..._one_installer

AstraS 18th April 2007 20:28

how can i change install path in directory page if before then i set MUI_DIRECTORYPAGE_VARIABLE

kichik 19th April 2007 18:04

Change the variable that you pass on to MUI_DIRECTORY_VARIABLE. In your example, it should be:
code:
Function .onInit
StrCpy $test_val $PROGRAMFILES\Test
FunctionEnd


AstraS 19th April 2007 20:57

:( it is not worked

kichik 19th April 2007 21:03

What exactly didn't work? What exactly did you do? I can't help you without any details.

AstraS 19th April 2007 21:03

function .oninit start before then i get $test_val, because
$test_val i can get, after installer setup firebird

kichik 19th April 2007 21:06

Then set it once you get it, as long as it's set before the directory page that uses it shows.

AstraS 20th April 2007 11:45

thx, i did it( for example i setup before directory page c:\Firebird\data), but if user change path in directory page (for example d:\temp\), installer put my file .....
into c:\Firebird\data anyway. :cry:
how can i do it?

kichik 20th April 2007 11:54

If it put the file in that directory, you told it to put it there. Try following the logic of your installer with message boxes so you see exactly when everything is executed. For example, add a message box saying "installing into test_val $test_val" and you'll see where and when it copies the files there.

Also read the tutorial for details about how everything works together. Pay special attention to Script Execution.

AstraS 22nd April 2007 10:33

Is someone know, how change MUI_DIRECTORYPAGE_VARIABLE from
MUI_PAGE_DIRECTORY .
thx

Comperio 22nd April 2007 18:26

This is in the MUI documentation:
Just insert !define MUI_DIRECTORYPAGE_VARIABLE $yourvariable just before you add the page.

Take some time to read through the rest of the MUI documentation included with NSIS. And see Kichik's last reply.

There is a lot of good info out there--you just have to reach out and grab it. :up:

AstraS 22nd April 2007 19:02

I read it, i use logic whith MessageBox, but i dont understend how chenge the path
PHP Code:

;--------------------------------
;Include 
Modern UI
  
!include "MUI.nsh"
;--------------------------------
;
General
  XPStyle on
  
;Name and file
  Name 
"B2"
  
OutFile "setup.exe"
  
;Default installation folder
 InstallDir 
"$PROGRAMFILES\B\B2"
;--------------------------------
;Interface 
Settings

  
!define MUI_ABORTWARNING
;--------------------------------

  Var 
test_val

;Pages

  
!insertmacro MUI_PAGE_WELCOME
  
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
  
!insertmacro MUI_PAGE_INSTFILES
  
!define MUI_DIRECTORYPAGE_VARIABLE $test_val
  
!insertmacro MUI_PAGE_DIRECTORY
  
!insertmacro MUI_PAGE_FINISH

;--------------------------------
Section "Dummy Section" SecDummy

  SetOutPath 
"$INSTDIR"
  
File "Firebird-1.5.3.4870-0-Win32.exe"

  
Delete $INSTDIR\Firebird-1.5.3.4870-0-Win32.exe
  RMDir $INSTDIR

  ReadRegStr $test_val HKLM 
"Software\Firebird Project\Firebird Server\Instances""DefaultInstance"
  
StrCmp $test_val "" "" +2
         StrCpy $test_val 
"C:\Program Files\Firebird\"
  StrCpy $1 
$test_val

  StrCpy $2 "
Data\"
  StrCpy "
$test_val" "$1$2"
  StrCpy 
$INSTDIR "$test_val"

  File "
B2.FDB"

SectionEnd


;--------------------------------
;Installer Functions

Function .onInit
  !insertmacro MUI_LANGDLL_DISPLAY

FunctionEnd 


AstraS 22nd April 2007 19:04

please, try to use my code.
maybe it is error there

Comperio 22nd April 2007 19:33

Well, right off the bat, I see some syntax errors with your use (or lack of) the backslash character:

Examples:
  1. You set INSTDIR at the beginning to $PROGRAMFILESBB2. There is no such variable. You probably mean to use "$PROGRAMFILES\BB2"
  2. Delete $INSTDIRFirebird-1.5.3.4870-0-Win32.exe should be:
    Delete $INSTDIR\Firebird-1.5.3.4870-0-Win32.exe
  3. ReadRegStr $test_val HKLM "SoftwareFirebird ProjectFirebird ServerInstances""DefaultInstance" should use this syntax:
    ReadRegStr $test_val HKLM "Software\Firebird ProjectFirebird ServerInstances""DefaultInstance"
    (I'm not sure the full registry path here, so you may need other \ characters in your path)
  4. StrCpy $test_val "C:Program FilesFirebird\" should be
    StrCpy $test_val "C:\Program Files\Firebird\"
    (note: you might not need the trailing backslash here, depending on what you trying to acomplish.)
Other than that, I think your code looks ok. (or if anything, it should get you a bit further.)

AstraS 22nd April 2007 19:48

Comperio
thx, but it is not syntax error(that errors appear when i insert my code in forum- message), it is logical error.
Becauese, when appeare MUI_PAGE_DIRECTORY it is use path from MUI_DIRECTORYPAGE_VARIABLE (it is equal $test_val)
BUT WHEN USER CHANGING PATH, AND NEW PATH APPEAR IN PATH-LINE ON PAGE, installer use old path (it is equal $test_val)
why???????????????????????

Comperio 22nd April 2007 20:21

Sorry, I didn't realize using [php] stripped the backslashes... (I guess this shows that [code] should be used instead of [php] in the forums when dealing with NSIS code.)

So back to your question:
Do you expect something to happen execute after MUI_PAGE_DIRECTORY? If so, you need to add a function for that.

Since you already used the sections when you inserted MUI_PAGE_INSTFILES, you'll have to execute the 2nd part using a leave function (which you can define with MUI_PAGE_CUSTOMFUNCTION_LEAVE)

kichik 22nd April 2007 20:54

Where in that example do you use $test_val beyond the directory page? It's set in the sections, displayed and modified by the directory page and then ignored.

AstraS 22nd April 2007 21:16

please show me how to do it.
thx

kichik 22nd April 2007 21:19

That strictly depends on what you actually want to do. You let the user modify $test_val and then do nothing with it. What do you want to do with it?

AstraS 22nd April 2007 21:23

yes. i want move File "B2.FDB" to user input path

kichik 23rd April 2007 12:33

Then why is the directory page after the instfiles page where the copy itself is made? If it's only for that ReadRegStr, put it in .onInit.
code:
Function .onInit
ReadRegStr $test_val HKLM \
"Software\Firebird Project\Firebird Server\Instances" \
"DefaultInstance"
FunctionEnd

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "license.txt"
!define MUI_DIRECTORYPAGE_VARIABLE $test_val
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH


AstraS 23rd April 2007 18:47

no!
i setup firebird in my installer, after .oninit.

Comperio 24th April 2007 02:13

If it's just the one file you want to copy, then I'd try this: First, remove this code from the end of your section:
code:

StrCpy $INSTDIR "$test_val"


then try this:

code:

;Pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}DocsModern UILicense.txt"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_DIRECTORYPAGE_VARIABLE $test_val
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE MoveFile
!insertmacro MUI_PAGE_DIRECTORY

!insertmacro MUI_PAGE_FINISH

Section
... your original section code here...
SectionEnd

Function MoveFile
; I asume these paths are correct. If not you may need to modify...
Rename "$INSTDIR\B2.FDB" "$test_val\B2.FDB"
FunctionEnd



Or, if the FDB file is large and you want to see some progress, you could use the CopyFiles function to copy the file and then delete the file in the original location.

AstraS 24th April 2007 10:53

Comperio, thx but no, i show a part of code. i cann't do your variant.
Maybe someone know how move only some file to place in path string ?

kichik 24th April 2007 11:33

You can have your installer gather all of the required installation details for Firebird and pass them on to their installer.
code:
ExecWait '$PLUGINSDIR\FirebirdSetup.exe /DIR="$test_val" \
/SP /VERYSILENT /NORESTART'

This way, you can show the directory page before the instfiles page and know exactly what the Firebird installer did.

AstraS 24th April 2007 12:08

thx all!!!!!!!!!!!!!!!!!!!!!!
I do it!
If it is interesting i'll show it there.(its Comperio
variant whith some changes)
thx all!!!!


All times are GMT. The time now is 04:10.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.