Old 27th September 2018, 14:33   #1
franklin91
Junior Member
 
Join Date: Sep 2018
Posts: 2
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
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:

code:
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 is offline   Reply With Quote
Old 27th September 2018, 15:15   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,926
You cannot mix and match compile-time and run-time instructions like that.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 27th September 2018, 15:17   #3
franklin91
Junior Member
 
Join Date: Sep 2018
Posts: 2
Quote:
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!
franklin91 is offline   Reply With Quote
Old 27th September 2018, 15:41   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,926
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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Tags
file, for-loop, nsis

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