BASIC |
|
|
The BASIC verb runs the QMBasic compiler.
Format
BASIC {file.name} {record.name...} {options}
where
When using a select list or an asterisk to compile all programs, the default action of the BASIC command is to ignore records with a .H or .SCR suffix. This omits include records that use the conventional .H suffix (header files) or .SCR suffix (screen definitions). The $BASIC.IGNORE record described below allows developers to change the rules of which, if any, records are skipped when using a select list.
Unless the KEEP.OLD.OBJECT mode of the OPTION command is active, any old version of the object code is deleted before the compilation commences. This ensures that developers who accidentally miss a compiler error message will not continue testing with the previous version in the incorrect belief that it is the new version.
The following options are accepted by the BASIC verb
The compiler output file, named as the source file but with a .OUT suffix, must be a directory file and will be created automatically if it does not already exist unless the file.name is a Q-pointer. The object code is stored in the output file using the same record name as the source. If a program listing is created, this is also placed in the compiler output file.
If all programs compile successfully, @SYSTEM.RETURN.CODE is set to the number of programs compiled. If any programs fail to compile, it will contain a negative error code.
Compiling a program signals an event to all QM processes to reload the object code. See the QMBasic CALL statement for full details.
Compiler options that you wish to use every time you run the QMBasic compiler can be placed in an X-type VOC record named $BASIC.OPTIONS. To apply these defaults only to programs stored in a specific file, place the $BASIC.OPTIONS record in that file. The compiler looks first in the source file (or the dictionary when compiling a C-type item) and then, if no record has been found, in the VOC.
The first line of the record holds the type code X. The second and subsequent lines of this record should contain compiler option keywords from the list below. The keywords allowed are:
SEARCH @, SYSCOM
Unrecognised keywords in this record are ignored.
Of the items listed above, only DEFINE, MODE, NOCASE.STRINGS and WARNINGS.AS.ERRORS are allowed in C-type items.
The $BASIC.IGNORE VOC Record
The default action of the BASIC command when using a select list or an asterisk to compile all programs is to ignore source records with a suffix of .H or .SCR. The $BASIC.IGNORE record allows developers to set their own rules controlling which, if any, records will be ignored. As with the $BASIC.OPTIONS record, the $BASIC.IGNORE record may be in the VOC or in the program file.
The first line of the record holds the type code X. The second and subsequent lines of this record contain pattern matching templates that are applied in turn to the source record id. If any of the templates match the source record id, the record is ignored. The default action of the BASIC command is equivalent to having a $BASIC.IGNORE record that contains: 1: X 2: ...'.H' 3: ...'.SCR' 4: '.GIT'...
Any record with an id that does not match any of the templates will be compiled. To compile all records, regardless of their name, create a $BASIC.IGNORE record that contains just the type code: 1: X
Concordance Data
The QMBasic compiler can create a cross-reference of subroutine usage through an entire application. The compiler will automatically create a file named BASIC.CONCORDANCE if it does not already exist. Compiling all programs with either the CONCORDANCE option on the command line or via the $BASIC.OPTIONS record will then generate the concordance data.
The BASIC.CONCORDANCE file will contain a record for each compiled program. The record id in this file is the uppercase form of the name in the PROGRAM, SUBROUTINE, FUNCTION or CLASS statement or, if no such line is present, the uppercase form of the program source file name. Field 1 (named REF) of each record is a multivalued list of all the external modules referenced by the program. In the case of an indirect call, the name appears as the @ symbol as the compiler cannot determine the actual name.
Using this file, it is easy to use the query processor to find all references to a particular subroutine or other relationships. For example...
Show a simple list of what subroutines are called from each program LIST BASIC.CONCORDANCE
Find all the programs that reference subroutine MYSUB LIST BASIC.CONCORDANCE WITH REF = "MYSUB"
Show a list of which programs call each subroutine LIST BASIC.CONCORDANCE WITH REF BY.EXP REF BREAK.ON "'OL'" REF @ID ID.SUP
Recompiling a module with the CONCORDANCE option set will update the file. The only time it will be necessary to make manual changes to the file is if a source program is deleted and its corresponding concordance record can therefore also be deleted.
Examples
BASIC PROGRAMS PROG1 LISTING
This command compiles the program in record PROG1 of the PROGRAMS file. A listing record is produced.
SELECT BP BASIC CHANGED
This sequence of commands compiles all programs in the BP file which have been updated since they were last compiled. Note that the compiler will omit all records with names ending with .H or .SCR, the two standard suffix codes for include records.
See also: |