Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
Not applicable

Script calling another script

Hi guys,

Is it possible to call one script from another?

In fact I have a script which needs to be executed at several times.

Its like defining a function and calling them over and over whenever needed.

I am not sure if it is possible or even a recommended way of writing scripts.

In case it is not a recommended way then how do we solve this kind of problem where a script needs to be executed at several points from different scripts?

Regards,

Saurabh

Tags (3)
1 Solution

Accepted Solutions
Not applicable

Re: Script calling another script

Hi Ramya,

As per my understanding for your query , I have some idea.

You can make use of subroutines.

For example:

Sub Test(vTable)

$(vTable):

Load * from $(vTable);

End Sub;

This can be your actual code which you write once in qlikview script itself and you can call n number of times later. Like below

Call Test('Pass the actual table name here')

If you have specific code or requirement, post you qvw

Hope it helps.

View solution in original post

11 Replies
MVP & Luminary
MVP & Luminary

Re: Script calling another script

Hi Ramya,

Place your script in a .txt or .qvs file and include this script file in QVW like this

 

$(Include=c:\DataLoadScript.txt)

When you reload the script in the text file executes.  Like this you can use in any n number of QVW files.

Regards,

Jagan.

Partner
Partner

Re: Script calling another script

Save your script in a txt file and you can use the include command.

Ex.

$(Include=include\ScriptInExternalFile.txt);

Best Regards.

Tonial.

Partner
Partner

Re: Script calling another script

Hi,

yes it is possible. You can create the script in a txt file and then you just have to include the script whenever you want to execute it.

amars
Valued Contributor

Re: Script calling another script

Hi Ramya,

I am not sure if you could write a function inside script but try using a For loop or a Do While loop inside your script and repeat whatever is necessary to be executed multiple times.

you can check the below link for more on loops

http://community.qlik.com/blogs/qlikviewdesignblog/2013/09/02/loops-in-the-script

Thanks...

Not applicable

Re: Script calling another script

Hi,

Ramya why you go for different script for using  functions you just use in the same script

Here is the sample function calling. we are writing a function for finding difference between two dates

SET MonthDiff = Num(((year($2) * 12) + month($2)) - (((year($1) * 12) + month($1))) + 1);

$2->Parameter2

$1->Parameter1

Function calling:

($(MonthDiff(Parameter1, Parameter2)))

Hope it will help you

Thanks and Regards,

S.Amuthabharathi

MVP
MVP

Re: Script calling another script

You can write macro function and call it in the script as and where needed. For more understanding refer this post . As of now you can't create function in the script,let's hope that would be incorporated in coming versions. Refer this for a related idea sharing.

Not applicable

Re: Script calling another script

Hi

the above suggestion are good

if u need more

we have call and sub function is there please check this functions.

write the script in the sub function

and

call it by using call function

Not applicable

Re: Script calling another script

Hi Ramya,

As per my understanding for your query , I have some idea.

You can make use of subroutines.

For example:

Sub Test(vTable)

$(vTable):

Load * from $(vTable);

End Sub;

This can be your actual code which you write once in qlikview script itself and you can call n number of times later. Like below

Call Test('Pass the actual table name here')

If you have specific code or requirement, post you qvw

Hope it helps.

View solution in original post

Not applicable

Re: Script calling another script

Hi,

Yes, it is possible. You can write your script in a text file and then include that file in your script.Something like this :

$(Include = C:\Myself\Qlikview\test.txt);

Where test.txt is the text file where your script is written. You can include this file wherever you want in your script.

Hope this helps!