Using Alternative Compilers
Overview
In order to create program object items that would run on an earlier version of Reality, you may need to use an earlier DataBasic compiler from the current default complier which would otherwise be used by the BASIC command.
Available compilers are shipped in the BASIC-COMPILERS system file in the SYSFILES account. Each complier will create object items that will run on its target release, and on any equivalent or earlier release. However, it will only recognise and compile DataBasic elements that are part of the subset defined for the target release.
There are several reasons why you might want to use an alternative compiler:
-
Code that compiled successfully on earlier versions of Reality fails to compile on the latest version; for example, because of additional reserved words. Ideally, you should correct the errors, but if this is not practical, you can compile with an earlier version of the compiler.
-
Your program needs to run on a system with an earlier version of Reality. In this case you must use an alternative compiler.
-
An alternative compiler is also useful to maintain live "current code" that is running on end-user systems while any testing is performed to make sure that any MultiValue compatibility changes, or new or updated features, are fully understood.
Which compiler is used by default?
Since Reality V15.2, you can define the default compiler as part of an operating environment maintained by either the SSM (System Security Maintenance) command in SSM Option 4 - Define Environment Settings, or the DEFINE-ENVIRONMENT TCL command (although both commands are restricted to the SYSMAN account).
Environments can in turn be associated with individual users though their user profiles, as defined in SSM Option 2 - Define User Profiles, so that the correct environment is loaded when each user logs on.
You can switch environments by using the SET-ENVIRONMENT TCL command, and this may also change the default compiler. If a default compiler is not specified in the current environment, the compiler identified by the BASIC*DEFAULT synonym entry in the BASIC-COMPILERS system file is used instead. Note that BASIC*DEFAULT is unchanged when upgrading to a newer version of Reality.
You can also temporarily override the default compiler by using the BASIC (C command option to select a different compiler.
Since Reality V15.2, the DataBasic SYSTEM(121) function returns the name of the current default compiler.
Changing the default compiler globally
Since Reality V15.2, the easiest way to globally change the default compiler is to create a new direct environment that references your preferred compiler and then point the DEFAULT environment at it.
Prior to V15.2, you would have to edit the BASIC*DEFAULT synonym entry in BASIC-COMPILERS to replace the contents of attribute 2 with the item-id of the required, loaded compiler item; the standard BASIC command would then use that compiler.
Available compilers
The following compilers are provided with Reality V15.4:
Compiler |
Reality version |
---|---|
BASIC*15.2 |
V15.2 |
BASIC*15.1 |
V15.1 |
BASIC*15.0 |
V15.0 |
BASIC*14.2 |
V14.2 |
BASIC*14.1 |
V14.1 |
BASIC*14 |
V14.0 |
BASIC*11 |
V11.0, V12.0 |
BASIC*10 |
V10.0 |
BASIC*09 |
V9.1 |
BASIC*08 |
V9.0 and earlier |
As well as these compiler entries there are also synonym entries such as BASIC*REALITY*4.3. These cannot be loaded directly and can only be used where the target synonym entry is loaded.
The BASIC*DEFAULT synonym entry identifies the default compiler, unless this is overridden in the current environment.
Loading compilers into the BASIC-COMPILERS file
The majority of compilers are pre-loaded by the system but if an historic compiler is required you can logon to the SYSPROG account and do the following:
-
First list the items in BASIC-COMPILERS,OPTOM and in BASIC-COMPILERS (default data section). BASIC-COMPILERS,OPTOM contains object items for the available compilers. Their item-ids indicate the main release for which they are suitable. BASIC-COMPILERS contains loaded compilers together with synonym items (showing Q in attribute 1) whose item-ids indicate other releases for which the associated OPTOM item (shown in attribute 2) is suitable.
-
If the compiler you need is not already loaded (the corresponding OPTOM item is not present in the default section of BASIC-COMPILERS), load it using the LOAD-BNF command as follows:
LOAD-BNF BASIC-COMPILERS,OPTOM compiler
DESTINATION FILE: BASIC-COMPILERSwhere compiler is the item-id of the OPTOM item. For example, BASIC*ROS*7.0.
Using the BASIC command with the C option
To use an alternative DataBasic compiler, enter the BASIC command with the C option as shown below:
BASIC file-name program-name (C
file-name The name of the file that contains the program you want to compile.
program-name The name of the program you want to compile.
(C Prompt for the compiler name.
At the prompt
Compiler name :
enter the name of the compiler you want to use. The names of the compilers are listed in the BASIC-COMPILERS file.
Cloning the BASIC command
If you find you are frequently using the BASIC (C command, you might want to create a new command that always uses your preferred compiler. To do this, copy the BASIC MD item to a new item with a suitable name (such as OLD-BASIC). Modify attribute 1 of this item to change the 'tag' (the character B) to some other single character (not G, O, or Q). For example, change attribute 1 from PB to PX. Then create an item in BASIC-COMPILERS with the new tag as its item-id, Q as attribute 1, and the item-id of the loaded compiler item in attribute 2.
MD entry BASIC 001 PB 002 2 003 BE 004 005 ZUP OLD_BASIC 001 PX 002 2 003 BE 004 005 ZUP BASIC-COMPILERS entry X 001 Q 002 BASIC*15.2
You can now use the new command to compile using the selected compiler.
A modified verb or a (C option have precedence over the environment compiler, which in turn has precedence over the BASIC*DEFAULT entry.