This article will cover the syntax of the ‘call’ control script statement

When a sub statement has been defined previously, the ‘call’ statement calls this subroutine to execute. You can pass specific parameters into the call statement.

Statement syntax



Name

This is the name of the subroutine to be executed. The subroutine must have been defined earlier in the script.

Paramlist

This is a list of parameters that will be passed to the subroutine being called. The list must be comma separated. It may include field names, variables or arbitrary expressions.

Important to know

Be aware that if a subroutine is defined within a logical control statement such as an ‘if… then’, the ‘call’ statement will only be able to call that subroutine from within the same statement. 

Example

This is an example of a simple subroutine for loading a specified QVD file. The file name is the variable passed into the subroutine during the call.

Sub Load (fileName)
	LOAD
    	*
    FROM [lib://Public:DataFiles/$(fileName)] (qvd);
End Sub
Call Load ('ITEM_DETAILS.qvd')

Result

After the subroutine is called, the file ITEM_DETAILS is loaded as a single table.