Old 21st September 2006, 08:23   #1
Rockem
Junior Member
 
Join Date: Sep 2006
Posts: 5
Select files to install from a list

Hello all,

I want to have an installer with files loaded in
so that I would have a list (with checkboxes) and I can check what I want to install and what not...

so far I created a listbox with the Embeddedlists plugin
and it works fine ..

my problem is .. how do I load the files to be inside
the installer and dynamicly tell the installer what to copy(install) and what not according to my list


I hope my problem is clear
thanx
Eli
Rockem is offline   Reply With Quote
Old 21st September 2006, 12:19   #2
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
To include files in your installer, you can use either "ReserveFile <file>" at the top of your script, or "File <filespec>" in a section or Function - even if you never end up using that section or Function. E.g. a hidden unselected section, or just never call that function.

As for when to install files or not, check the examples for EmbeddedLists. I found the following bit in ListView_CheckBoxes.nsi:

code:

Function ListViewLeave
StrCpy $R1 `` ; Clear checked items list.
Pop $R0 ; Checked item text.
StrCmp $R0 /END +3 ; No item checked?
StrCpy $R1 $R1|$R0
Goto -3 ; Loop.
; etc.




All this does is create a string with each checked item's name delimited by a "|" character. You can easily retool this to install files, or not:

code:

Function ListViewLeave
StrCpy $R1 `` ; Clear checked items list.
_loop:
Pop $R0 ; Checked item text.
StrCmp $R0 /END _end ; No item checked?
StrCmp $R0 "filename.ext" 0 +3
SetOutPath "c:\some\path\"
File "filespec"
StrCmp $R0 "anotherfilename.ext" 0 +3
SetOutPath "c:\some\other\path\"
File "filespec"
; etc.
Goto _loop ; Loop.
_end:



Note that this would start installing files as soon as you leave the ListView page. If you want this done later, then you should retool the original code to put the "|"-delimited in a variable that you'll access from a later page. You can then use the StrCpy and StrCmp commands to go over that list and do much the same as in the adjusted example above.
Animaether is offline   Reply With Quote
Old 21st September 2006, 13:52   #3
Rockem
Junior Member
 
Join Date: Sep 2006
Posts: 5
Do I HAVE to specify every file I want to work with ?
can't I pass File a parameter ?

Its just that the files are dynamicly changing
(thers a script that creates th ini file automaticly)
Rockem is offline   Reply With Quote
Old 21st September 2006, 14:10   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Using the File instruction puts the file into your installer executable. If you just want to copy the file from one place to another, use CopyFiles.

-Stu
Afrow UK is offline   Reply With Quote
Old 21st September 2006, 14:27   #5
Rockem
Junior Member
 
Join Date: Sep 2006
Posts: 5
can CopyFile copy from inside the installer ??

How do I direct it ?
Rockem is offline   Reply With Quote
Old 21st September 2006, 14:53   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
As I've already explained, File puts the file into your installer and extracts it to $OUTDIR.
Use the SetOutPath instruction to set the current output folder.

-Stu
Afrow UK is offline   Reply With Quote
Old 21st September 2006, 15:00   #7
Rockem
Junior Member
 
Join Date: Sep 2006
Posts: 5
ok .. but this is the thing
I need to extract only files that have been selected in the list.
and the file list is dynamic, so I need to put parameter
in File, but I can't

is there something else that I can do ?
Rockem is offline   Reply With Quote
Old 21st September 2006, 15:43   #8
Rockem
Junior Member
 
Join Date: Sep 2006
Posts: 5
What I eventualy did is
to extract akk the files to a directory in $TEMP
copy what I need and then delete that directory ..

if there is a smarter way .. pls share
Rockem is offline   Reply With Quote
Old 21st September 2006, 16:37   #9
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You can jump over the File instructions if they aren't in your list. It might be easiest to store your file names in an array using the NSISArray plugin.

-Stu
Afrow UK is offline   Reply With Quote
Old 22nd September 2006, 01:41   #10
aryu
Junior Member
 
Join Date: Sep 2006
Posts: 4
how do I load the files to be inside the installer according to my list, so that I don't have to change my script every time when the files to be installed changed.
aryu is offline   Reply With Quote
Old 22nd September 2006, 10:57   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I'm confused now. Surely your list needs to be read at run time? You can't modify which files are in the installer at run time, because the files are placed in the installer at compile time!
All you can do, is include all the files inside the installer, and extract only those required.

-Stu
Afrow UK 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