Old 8th July 2015, 21:33   #1
MikeMNN
Junior Member
 
Join Date: Jul 2015
Posts: 1
Path from file

Hi,everyone!

My problem: I'm trying to get the pathes from txt file. Every line of file is a path. But i wanna to get global pathes from file like this

FileOpen $4 "$DESKTOP\SomeFile.txt" r
FileRead $4 $CurrentGarbage
Push $CurrentGarbage
Delete $CurrentGarbage
Pop $CurrentGarbage
FileClose $4

Where line may be like this $PROGRAMFILES\example\example.txt.
I wanna of my installer to understand, that $PROGRAMFILES is a variable from file, can i do this? I tryied to make it like ${PROGRAMFILES}, all string in quotes, without anything, but it doesn't work.. If i type path C:\Program Files (x86)\example\example.txt - it works. Is there a way to solve my problem?
MikeMNN is offline   Reply With Quote
Old 9th July 2015, 04:11   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 923
Unfortunately you can't read in variables like this at runtime. One way to get around this is to use relative paths in the .txt file, and keep the nsis variables within the script. If you have multiple variables, you might need an identifier in the .txt file so that you know which variable to use, although this can lead to outside processes modifying the .txt for bad purposes so I don't recommend it.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 9th July 2015, 07:53   #3
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
You could try replacing the variables in your string manually:
http://nsis.sourceforge.net/StrRep

${StrRep} '$CurrentLine' '$CurrentLine' '$$PROGRAMFILES' '$PROGRAMFILES'

Please notet the double-$ in the the "to be replaced" string, which is required for escaping the $ sign! Otherwise you'd be replacing the current value of $PROGRAMFILES with the current value of $PROGRAMFILES, which is kind of a NOP.

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR 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