Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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.
Save your script in a txt file and you can use the include command.
Ex.
$(Include=include\ScriptInExternalFile.txt);
Best Regards.
Tonial.
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.
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...
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
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
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.
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!