compile command

The compile BASIC program invokes the BASIC compiler and translates the specified source code into executable object code with case insensitivity.


compile file.reference itemlist* {(options}




options c Compresses the object by suppressing the end-of-line (EOL) opcodes from the object code item. This option is designed to be used with debugged and cataloged programs. Because the EOL opcodes are used to count lines for error messages, any runtime error message in a program compiled with the c option indicates the error is on line 0. Additionally, the c option removes the ability to single-step with the BASIC debugger.
  d Prevents the runtime d option from entering the debugger.
  e Lists only error lines encountered during the compilation of the program.

The listing indicates line number in the source code item, the source line itself, and a description of the error associated with the line.

  f Generates floating point arithmetic when used with the o option.
  g For UNIX: Not supported

For Windows: Produces object code that is stored as an MS-DOS file with the extension .D3F.

  h Forces the module to be loaded locally and is typically for modules that are being used by only one or two people at any given time.

By default, the BASIC compiler attempts to create native code that can be shared by all users. This option is only supported when used with the o option.

  i Lists lines from any included program as part of the listing. If used with the l option, the source program listing, the included lines are indicated by a plus sign after the line number.
  j Allows compile options to be embedded in the source code at:

$OPTIONS <platform> <options>

  k For Windows: Not supported

For UNIX: When used without the h option, forces shared code to remain loaded until the machine is shut down.

This option should be used for those programs that are used by the majority of users on the system. It reduces memory usage and load time.

  l Generates a line-by-line listing of the source program during compilation.

Error lines with associated error messages are indicated. When the l option is used, the asterisk does not display. Each line of the listing takes place at the asterisk.

  m Generates a program map of the descriptor table and correlates source code lines to generated object code frames. Each variable in the program is listed along with its decimal offset.
  n No pause (nopage) option: Suppresses pause at end of page on terminal display.
  o Produces a FlashBASIC optimized code.
Note: If any module in a program is compiled with the o option, then all modules in that program must also have been compiled with the o option.
  p Routes all output generated by the compilation, except the cross-reference listing, to the printer, via the spooler.
  q Prevents messages from scrolling past on terminal
  s Suppresses generation of a symbol table. The symbol table is used exclusively by the BASIC/FlashBASIC debugger for reference; therefore, it needs to be kept only if the user uses the debugger.
  x Creates a cross-reference of all the labels and variables used in the BASIC program and stores this information in the bsym file, which must exist before using. The x option first clears data in the bsym file, then creates an item for every variable and label used in the program, using the variable or label name as the item-ID.

After creating the cross-reference items, attribute one contains the line numbers where the variable or label is referenced; each line number is a value. The line number where a label is defined, or where the value of the variable is changed is preceded by an asterisk. If the variable names and labels are in both uppercase and lowercase, the D-pointer for the bsym file-defining item should not have the s option.

  w Optimizes without source when used with the o option. This allows optimizing programs without source code.
Note: The normal dictionary object statistics are not updated when this option is used.
  y Allows multiple FlashBASIC or BASIC compiles concurrently. Normally, each BASIC or FlashBASIC compile attempts to set BASIC lock 49 to keep multiple compiles from dramatically slowing down the machine. The y option avoids this logic.

Case insensitivity means that the variables TOTAL, Total, and total all represent the same symbol. A case-sensitive state would treat these as three separate variables.

Each line of the source program is scanned for syntax errors during compilation, even after an error has been detected.

A period displays for every 10 lines of code.

If an error is encountered, the line with the error and the error message displays; no object code is produced.

If the o option is used, FlashBASIC is invoked after the first stage of compilation is complete. When all stages are completed, and if no errors are found, the compiled form is saved and can be executed using the run command. The program may also be cataloged with the catalog command.

The itemlist* consists of one or more source program names, separated by spaces. If a name is not specified, or if the * (asterisk) is used, all programs in the file are compiled.

Programs can be created and modified using the Update processor. Additionally, programs can be compiled when exiting the Update processor by using either the CTRL+XC command, which compiles and catalogs the program, or the CTRL+XR command, which compiles and runs the program. Any other editor can also be used.

For UNIX: The default options can be stored in attribute 6 of the compile item in your master dictionary. For example, putting an o in this attribute makes all compiles in that account produce FlashBASIC code.

Warning: Compilation with the (o flag might take a long time to compile and tends to use a great deal of the machine’s resources.

An error encountered deep within nested logic can produce several screens of erroneous error messages. The actual error is the first message listed.


Example 1

Compiles the term-type program and sends the listing to the printer.

compile dm,bp, term-type (lp

Example 2

Creates a BASIC native object module that can be run from D3 as if it were an interpreted BASIC program. The c option is used primarily to reduce object size and compile time, both of which can be significantly greater when using BASIC.

compile bp j (oc

Example 3

The embedded options are ignored unless the compiler is invoked with the j option:

compile bp * (j

The embedded options are added to the TCL options.

Example 4

Creates FlashBASIC code for all the FlashBASIC object pointers in bp.old. There is no need to have the source present.

select dict bp.old

[404] 114 items selected from 114 items.

compile bp.old (ow

ct       md             compile
001      VR
002      3]9
003      F
004      dm,bp,         :ccompile
006      o

Notice that an o was placed in attribute 6. When this command is invoked, compile programs are flashed.