QPR Knowledge Base 2016.1

QPR Scripting

QPR Scripting

Previous topic Next topic No directory for this topic  

QPR Scripting

Previous topic Next topic Topic directory requires JavaScript Mail us feedback on this topic!  

QPR Scripting enables easy access to the QPR API commands. Scripts are programs written in VBScript (Visual Basic) that can handle typical automated model administration tasks or integrate QPR Products with other applications. QPR Scripting utilizes standard Microsoft Windows Scripting capabilities with the addition of the QPR Application Object Model.

 

In the case you are not familiar with Visual Basic Scripting (VBScript), please see the language reference and User's Guide at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriVBScript.asp.

 

Scripts are extremely useful for automating certain model operations. You can, for example, define an XML export to be performed silently (i.e. no user interface is displayed) at a certain time, after which the data can be used in a third party tool. You can also create and update QPR Metrics models by using scripts.

 

When writing scripts for QPR products, the scripts must have <QPR_SCRIPT_FILE> as the very first line (header) of the file without any kinds of lines (including blank ones) preceding the QPR script header line. There are different options that can be added to the script header. See the Script Header Settings chapter for more information about the different settings. The scripts must be saved as *.qprmsc (QPR Metrics) and *.qprpsc (QPR Modeling Client) files.

 

To have the name and description of the script displayed in the Run Script menus in QPR Metrics client and QPR Modeling Client, use the following tags in the beginning of the script:

<NAME Name for the script>

<DESCRIPTION Description for the script>

The name and the description may not contain the '<' or '>' characters.

 

To have the script displayed as a a separate button in the Ribbon in QPR Metrics and QPR Modeling Client instead of under the Run Script menu, use the following tags in the beginning of the script:

<BUTTON_PLACE Name of the Ribbon tab where to place the button> - Mandatory. Tab name is matched according to the localized tab names of the selected user interface language at client startup. If a matching tab name isn't found, a new tab will be placed on the Ribbon. If not defined, script will be placed under the Run Script menu.

<BUTTON_GROUP Name of the group in the Ribbon tab where to place the button> - Optional. Default value is "Scripts".

<BUTTON_NAME Name of the button> - Mandatory.

<BUTTON_IMAGE Path to an image file to be used as the button image> - Optional. Supported image files are bmp, jpg, png, and gif. Default image is the same image used for the Run Script button.

 

Note that it's recommended to save the script with UTF-8 encoding if you want to display the script in the separate button in the Ribbon.

 

The scripts must always contain a "Sub Main" procedure, from which the script's execution is started. Both xxAplication and xxModel objects are initialized for scripts automatically.

 

The following chapters provide you with example scripts that you can use as a basis when building your own scripts. You can also find some example scripts in Appendix A.