Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Specialist II
Specialist II

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

View solution in original post

7 Replies
gandalfgray
Specialist II
Specialist II

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
Author

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

rbecher
MVP
MVP

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

Astrato.io Head of R&D
Not applicable
Author

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
Author

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

gandalfgray
Specialist II
Specialist II

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.

rbecher
MVP
MVP

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

Astrato.io Head of R&D