Databases Reference
In-Depth Information
On the
Aircrafts
tab, we used the
CALL TraceRowCount('Aircraft Types');
statement to show the number of records in the
Aircraft Types
table before and
after joining the engine configuration information to it.
Including script files
As we have seen in the previous section, we can use subroutines to re-use pieces
of script within a QlikView document. It is also possible to re-use script between
documents by including external script files. Re-using script between documents
is a worthwhile goal as it eases development and simplifies maintenance.
We will see how we can take the row count subroutine that we created in the
previous section and turn it into an included script file that we can use in all of our
documents. Let's follow these steps:
1. Open the
Script Editor
and navigate to the
Subroutines
tab.
2. Select and copy the entire
TraceRowCount
subroutine to the clipboard by
pressing
Ctrl
+
C
.
3. Open Notepad (by pressing
Windows Key
+
R
, typing in
notepad
and
pressing
Return
) or any other text editor.
4. Paste the
TraceRowCount
subroutine to Notepad.
5. Save the file to the same folder you used for the QlikView document
and call it
TraceRowCount.qvs
.
6.
Close
Notepad
and return to QlikView's
script editor
window.
7.
Go to the
Subroutines
tab and remove the script for the
TraceRowCount
subroutine.
8.
Select
Tab | Rename
from the menu and rename the tab to
Includes
.
9.
Select
Insert | Include Statement
and select the
TraceRowCount.qvs
file.
The resulting code should look like this:
$(Include=tracerowcount.qvs);
This statement tells QlikView to include the contents of the script file in the
current script.
In this example, we put the script file in the same folder as
the QlikView document. In a real environment, we would
set up a folder structure with an
include
or
library
folder that contains all reusable scripts.