21.01.2013 Views

QlikView Reference Manual.pdf - QlikCommunity - QlikView

QlikView Reference Manual.pdf - QlikCommunity - QlikView

QlikView Reference Manual.pdf - QlikCommunity - QlikView

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Variable Events:<br />

l A macro can be run when a new value is directly entered into a specified Variable (page 171).<br />

l A macro can be run when the value of the specified variable changes as a result of changes in other<br />

variables or the logical state of the document.<br />

Macros that are invoked from variable events are created from the Document Properties: Triggers (page<br />

425) page.<br />

Macro Editor:<br />

Irrespective of how they are triggered, macros are created and edited in the Edit Module (page 875) dialog.<br />

Examples of Macros<br />

This section gives you an example of a VBScript macro, which can be very useful.<br />

Using VBScript Input Boxes for User Interaction<br />

rem ** Clear selections, ask for product, **<br />

rem ** select that product, **<br />

rem ** go to sheet "Market", **<br />

rem ** show pivot table "Sales" **<br />

Sub ChooseValue<br />

Set q = ActiveDocument<br />

q.ClearAll (false)<br />

Set f = q.Fields("Model Name")<br />

x = inputbox ("Enter product")<br />

f.Select(x)<br />

set s = q.Sheets("Market")<br />

s.Activate<br />

s.SheetObjects("Sales").Activate<br />

end sub<br />

79.2 Special Library Functions for JScript<br />

Whereas the standard VBScript functions InputBox and MsgBox can be used freely in VBScript macros, no<br />

direct counterpart is available when using JScript. For this purpose a special library qvlib has been added for<br />

these actions. The functions are demonstrated in the example below.<br />

// JScript<br />

function Test()<br />

{<br />

personName = qvlib.InputBox("What is you name?")<br />

msg = "Hello " + personName + " !"<br />

qvlib.MsgBox(msg)<br />

}<br />

The qvlib functions actually work also in VBScript macros as shown in the example below, but in this case<br />

you might as well use the generic VBScript functions InputBox and MsgBox.<br />

874<br />

rem VBScript<br />

sub TestModule

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!