Filing and retrieving statements
Quick reference
To include one data file in another, or to include a file of Quantum statements in the main program file, type:
#include file_name
*include is an alternative to #include
More information
Programs can be split up into logical units, for example, edit, tabs, and axes, with each group of statements saved in a different file.
A program is most likely to contain groups of identical statements when a series of tables is reproduced a number of times using different filters. For example, you might need to produce a series of tabulations by area of residence, and for each area you require the tables:
tab brand demo
ttcBrand Bought Most Often
tab prefer age
ttcBrand Preferred
tab demo bk01
ttcDemographic
This could be done using a flt statement for every area and writing out these statements five times, thus:
flt;c=c121'1'
ttlBase: Respondents Living in Central London
tab brand demo
ttcBrand Bought Most Often
.
.
but it is more efficient to create a new file containing the tabs and tts instead. Call it tab1.
To create these tables, you must tell Quantum to read the file. To do this, put an *include or #include line in the program where you want the file to be read. (There is no difference between *include and #include; these examples use #include.)
For example:
flt;c=c121'1'
ttlBase: Respondents living in Central London
#include tab1
flt;c=c121'2'
ttlBase: Respondents Living in Outer London
#include tab1
flt;c=c121'3'
ttlBase: Respondents Living in England Outside London
#include tab1
.
.
This example can be abbreviated even further by using symbolic parameters for the items which differ from filter to filter. This is discussed below.
If tab1 is in the same directory as the rest of your program, you have to enter only its filename. If the include file is in a different directory or partition, you must give its full path. It is an error if a specified file does not exist, and Quantum generates a message saying it is unable to find the file. Quantum also generates an error message if there is any other problem such as ‘permission denied’.
The first time a file is included, Quantum lists its contents in the output listing, but whenever it is included again in the same program, only the include statement is printed so that you can see which file Quantum has read in.
An include file can itself include other files: for example, the file called subs can include the contents of a file called ax9A. Each time you call up subs, you are also calling up ax9A. This is called nesting.
The statement #include filename can appear in a Quantum data file as well. Includes can be nested in a data file to four levels: that is, the main data file can contain an include statement to call up the file DATAB, which itself includes DATAC which in turn includes DATAD:
Main data file |
| | | | | | |
#include DATAB | |
| | | | | | |
| #include DATAC |
| | | | | |
| #include DATAD |
See also