Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

"functions" available in load script

Hi all,

I know I can create subs in qlikview, but can you also create a function in the script?

e.g

function CheckIfFileExists(filename)

     bla bla

end function

next to this: it seems qlikview only accepts subs with at least one parameter? (I am now using a dummy value as parameter)

PS: I don't want to use macro's for this (unless it is the only way. I want to have all coding in the script)

Thanks for your replies!

1 Solution

Accepted Solutions
gandalfgray
Valued Contributor

"functions" available in load script

Hi

There are no "functions" in QV, just "subs"

You should be able to have subs without parameters. (I have)

You just define it without a parenthesis after if you do not want parameters

/gg

7 Replies
gandalfgray
Valued Contributor

"functions" available in load script

Hi

There are no "functions" in QV, just "subs"

You should be able to have subs without parameters. (I have)

You just define it without a parenthesis after if you do not want parameters

/gg

Not applicable

"functions" available in load script

No, I don't believe you can have VB functions in load scripts. You can however do loops - for example, while, for etc. which you might find useful

MVP
MVP

Re: "functions" available in load script

At least you can have Subs with parameters..

It is possible to use VBScript or JScript functions in the load script but it slows down the load process and the load statement cannot be spread into parallel threads.

- Ralf

Not applicable

Re: "functions" available in load script

Hi Thank you.

I don’t need VB/java functions. I would just like to have the “function” à a sub that returns a value

Is that also not possible? The ref. manual only refers to subs.

Thanks!

Not applicable

Re: "functions" available in load script

A thanks, that is the answer. But it is not possible to provide a return value then?

gandalfgray
Valued Contributor

Re: "functions" available in load script

Not a proper "return value", however all variables used in the sub are also available from the outside, so you can assign a variable a value in the sub which are accessible from the calling environment.

MVP
MVP

Re: "functions" available in load script

You could use variables as functions for simple tasks like this:

SET FileExists = if(len(FileSize($1)) > 0, -1, 0);

LET vExists = $(FileExists('dir\filename.ext');

// from Rob Wunderlich´s Qlikview Components (QVC)

- Ralf

Community Browser