Skip to main content Skip to complementary content

VBScript function calls from script

Functions defined in the VBScript module of a QlikView application can be called from the script. If a function called is not recognized as a standard script function, a check will be made to see if a custom functions resides in the module. This gives you a large degree of freedom to define your own functions. The ActiveDocument Object cannot be used in functions called from the script. Using custom VBScript functions will of course be somewhat slower than executing the standard functions.

Examples

Example 1: VBScript module

rem ********************************************************** rem ********** THIS IS VBSCRIPT CODE FROM THE MODULE ********* rem ********************************************************** rem ******************** Global variables ******************** dim flag rem *************** functions accessible from script ********* rem ********************* wrap for inputbox ****************** function VBin(prompt) VBin=inputbox(prompt) end function rem ********************* clear global flag ****************** function VBclearFlag() flag=0 end function rem ***************** test if reference has passed *********** function VBrelPos(Ref, Current) if Ref=Current then VBRelPos="Reference" flag=1 elseif flag=0 then VBRelPos="Before "&Ref&" in table" else VBRelPos="After "&Ref&" in table" end if end function

Example 2: QlikView script

// ********************************************************** // ******************** THIS IS THE SCRIPT ****************** // ********************************************************** let MaxPop=VBin('Max population in millions :'); // Ask limit let RefCountry=VBin('Reference country :'); // Ask ref. let dummy=VBclearFlag(); // Clears the global flag Load Country,recno(), Capital, "Area(km.sq)", "Population(mio)", VBrelPos('$(RefCountry)',Country) as RelativePos from country1.csv (ansi, txt, delimiter is ',', embedded labels) where "Population(mio)" <= $(MaxPop);

Transfer of parameters

The following rules apply for parameter transfer of parameters between the load script and VBScript:

  • Missing parameters are passed as NULL.

  • If the actual expression evaluates to a valid number, the number is passed,

    else if the actual expression evaluates to a valid string, the string is passed,

    else NULL is passed.

  • NULL is passed as VT_EMPTY.

  • Return values are treated in a natural way.

 

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!

Join the Analytics Modernization Program

Remove banner from view

Modernize without compromising your valuable QlikView apps with the Analytics Modernization Program. Click here for more information or reach out: ampquestions@qlik.com