File Access Commands
Getting Specifications from an ASCII File
Data entry questions, questionnaire control statements, groups of questions, header information, and large response lists from previous questionnaires can be brought into a current questionnaire.
When a questionnaire is compiled, PREPARE automatically saves all the specifications in an ASCII (QSP) file. You can copy an entire ASCII file, or any portion of one, into a current questionnaire — editing it as needed.
The syntax for reading in a specification file (at the PREPARE–> prompt) is:
&filename
Filename is any valid file name. With the above syntax, the specifications in the file will be read into the program and displayed in the list file.
You may want the file brought in without displaying the specifications in the list file.
The syntax for this is:
&-filename
&? says that if the file referenced is not found, skip over it and don’t generate an error. Another option is to specify just a portion of a file, by using the slash (/) delimiter:
&filename(parameter 1/parameter 2)
This syntax is used to indicate that you want only the part of the file from the first occurrence of the first parameter to the next occurrence of the second parameter. A parameter can be a question number, a string of ASCII text or a line number.
Specification Parameters
To locate the beginning of questions, PREPARE places a commented question number before each question in the QSP file. CFMC’s comment character is the apostrophe. Commented question numbers take the form ‘..
EXAMPLE:
&HOSPITAL.QSP('0.05/'1.10)
With this syntax, PREPARE would bring in everything from the beginning of question .05 to the beginning of question 1.10. PREPARE is searching for this comment beginning in column 1 of your spec file.
Because commented question numbers precede the questions, it is important that the second parameter be beyond the last question desired. In the above example, only the comment line before question 1.10 would be included.
You may also reference a file by line number, or specific characters in the file. (See Utilities for more information).
Using Comments in Specification Files
There are many ways to put comments or comment out items in a file. You can put comment lines in your specification files for your own documentation. A simple way to do this is by using apostrophes (”). Two apostrophes may be used to comment out everything to the right on that line.
EXAMPLE:
'' The next question has to do with credit cards { CREDITCARDUSE: Do you use credit cards? ''question text !FIELD ''question type 1 Yes ''first response code 2 No ''second 9 DON’T KNOW/NOT APPLICABLE } ''last line of question
In this example, all the text on the right (following the double apostrophes) will not affect the specifications. They are simply explanatory notes. They will not appear on the screen during the interview. Make sure you use two single apostrophes, not one double quote.
These comments will be passed to the QSP file. You can also annotate spec files with comment blocks that PREPARE will pass to the QSP file.
The syntax for using comment blocks in spec files is:
{!COMMENT <text lines> }
The format is similar to other compiler commands but you can have approximately 100 lines of text and use any special characters inside the block. You can comment out a whole question by placing a {!COMMENT in front of the question’s open {, just do not add another closing } or you will get a spec error. As soon as a closing brace is seen, the Comment block is ended. If you need to create a Comment block around a group of questions, use the REMOVE and END_REMOVE compiler commands.
You do not need an ampersand (&) to continue to the next comment line, just type as you would normally. The closing } brace can be at the end of the last line of text or on the next line.
NOTE: COMMENT must come after the study header. If you want comments at the top of your spec file use the apostrophe comment characters but remember these lines will not get passed to the QSP file.
Here are some examples of how comments are used in the spec file.
{!COMMENT only one line of text } {!COMMENT text does not need to start on same line text line 1 text line 2 special characters are allowed }
NOTE: Meta commands in column 1 are dropped from the Comment block passed to the QSP file and do not execute. Here is an example:
Spec file: QSP file: {!COMMENT {!COMMENT} >DIR } {!COMMENT >DIR} {!COMMENT >DIR}
You may also comment out any question or compiler directive by using a minus sign (-) after the open-brace that begins the item:
{-Q3: ”minus sign causes this question not to execute
This is the text of the question
!FIELD
1 One
2 Two } ‘’ends this ‘commented out’ question