Skip to content
⌘ NSIS Forum Archive

Pass a variable into File function in for loop cycle

4 posts

franklin91#

Pass a variable into File function in for loop cycle

My problem is this: I cannot pass variable inside a for loop, it seems that it does not recognize the variable. It takes the string with the variable, but not the variable value. This is my code
!define FORMAT "XY 2018|XY 2019"

!include "LogicLib.nsh"
!include "Explode.nsh"

# set the name of the installer
Outfile "example.exe"

# create a default section.
Section

${Explode} $0 "|" "${FORMAT}"
${For} $1 1 $0
Pop $2
!define PATH_OK "Z:\XY\Doc\List\*$2*"
File "${PATH_OK}"
${Next}

SectionEnd
When I'm going to compile the nsis file, it returns this error:

File: "Z:\XY\Doc\List\*$2*" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
/oname=outfile one_file_only)
Error in script "C:\Users\Francesco\Desktop\example.nsi" on line 19 aborting creation process
I can't understand why... if I try to change the code File "${PATH_OK}" with a messagebox the path results ok. Where am I doing wrong? Many thanks to all!
franklin91#
Originally Posted by Anders View Post
You cannot mix and match compile-time and run-time instructions like that.
Thanks for the reply Anders, do you know a method to solve my problem?
Many thanks!
Anders#
The File instruction only knows the basic DOS wildcards, if you need something more advanced then you need to build a file list by executing something with !system and a batch file or something like that.