Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Include Statement with a variable relative path

I'm looking to manager a large number of qvw files across multiple platforms.  In an attempt to centralize and ease maintence, change requests and version control, I'm converting my scripts into .txt files and referencing them as $(include) statements in my scripts.  I'm using relative paths.  However, the path of where these files may reside could very well change too so I'm looking to make the relative path a variable as well. 

How can I make my $(Include) statement include another $(variable) that contains a path?

Normal include:

$(Include=..\..\loader scripts\loader_dim_location.txt);

But I want something like this:

Let $(LoaderPath) = '..\..\loader scripts\';

Let $(DynamicInclude) = '$(Include=' & $(LoaderPath) & 'loader_dim_location.txt)';

$(DynamicInclude);

This doesn't error, it just doesn't work. 

1 Solution

Accepted Solutions
Not applicable
Author

Try not using $ while assgining a variable.

Let LoaderPath = '..\..\loader scripts\';

is the correct usage

Use $ whenever you want to substitue variable with the value it is holding

View solution in original post

7 Replies
Not applicable
Author

Try not using $ while assgining a variable.

Let LoaderPath = '..\..\loader scripts\';

is the correct usage

Use $ whenever you want to substitue variable with the value it is holding

Anonymous
Not applicable
Author

In case anyone has similar problems, under SR11 I seem to need to use the following lines (ClientDefDir is what was called LoaderPath in the example above):

LET DynamicInclude = '(Include=$(ClientDefDir)\script_client_language.qvs)';

$$(DynamicInclude);

Not sure why I had to do this double dollar expansion on the include line.

Jonathan

Anonymous
Not applicable
Author

Update to this. Seems you don't even have to do the initial variable declaration as the following works fine:

    $(Include=$(ClientDefDir)\script_client_language.qvs);

Jonathan

lenka_kruse
Partner - Contributor III
Partner - Contributor III

Hi,

I'm using the latest QV-Version (11.20.12354.0409, x64) and I still have the problem that the include-statement doesn't work if I include a path-variable.

I use centrally defined absolute paths:

// Root-Folder

set vP_Root = \\qvap\blabla\Source_Docs\;

// System-Folder

let vP_01_Meta = '$(vP_Root)01_Metadaten';

let vP_02_Include = '$(vP_Root)02_Include';

I want the include-statement to use the pre-defined path that points to the 02_Include-folder:

$(Include= $(vP_02_Include)\skript_metadaten.txt);

With that syntax, however, it doesn't work. No error-message, just no inclusion of the script-file. In Debug-Mode, it just shows the content of the vP_Root- and vP_02_Include-variables in the script-position where the include-file should be shown.

Does anybody have a clue what I'm doing wrong in the syntax?

lenka_kruse
Partner - Contributor III
Partner - Contributor III

Problem solved - the absolute path contained a folder with a space, and it looks like the include-statement can't deal with spaces and just sulks and refuses to work

With a space-less path, Jonathan's syntax works just fine.

rsdhavle
Creator II
Creator II

Can i pass multiple paths in this scenario? I want to pass multiple path locations in QVS path of system monitor application

Kalmer
Partner - Creator
Partner - Creator

I know this is an old post but i solved it like this.
It's a newbie way but works flawlessly.

LET vOSuser = subfield(OSuser(), '\', -1);
LET vPath = 'C:\users\$(vOSuser)\Desktop\';

Txt_Docs:
Load * inline [
NrOfDoc, DocName
1, 1.Demo_data.qvs
2, 2.Calendar.qvs
3, 3.Measures_and_Variables.qvs
]
;
//4, 4.Call_subs.qvs

ERRORMODE=0;
LET NumRows=NoOfRows('Txt_Docs');

 FOR i=1 to $(NumRows);
 LET vDocName = Peek('DocName', $(i)-1, 'Txt_Docs');
 LET vDocument = '$(vPath)' & '$(vDocName)';
 LET vDollarSymbol = chr(36);
 LET vDynamicInclude = '$(vDollarSymbol)' & '(Include=' & '$(vDocument)' & ');';
 
 trace $(vDynamicInclude);
 $(vDynamicInclude);

next

$(Include=C:\users\$(vOSuser)\Desktop\4.Call_subs.qvs); ERRORMODE=1;