$MODE Compiler Directive

Top  Previous  Next

 

The $MODE directive enables language options for improved compatibility with other multivalue databases.

 

 

Format

 

$MODE option {, option...}

 

where

 

option        is the feature to be turned on.  Multiple comma separated option names may be given.

 

 

The available options are:

DEFAULTTurn off all options.
AUTOLOCKAutomatically locks a record if not already locked on WRITE or DELETE. This is provided for compatibility with some other environments and is not recommended.
CASE.SENSITIVEEnables case sensitivity for names of labels, variables and user defined functions.
CHANGE.NO.OVERLAPDo not allow overlapping substrings in CHANGE(), EREPLACE() and SWAP().
COMPATIBLE.APPENDModifies the behaviour of the append modes of the S<f,v,sv> assignment operator, the INS statement and the INSERT() and REPLACE() functions to match that of other multivalue products.
COMPOSITE.READNEXTModifies how a READNEXT statement handles exploded select lists.
CONDITIONAL.STATEMENTSAllow most statements that have a THEN/ELSE clause to be used as conditional elements in WHILE or UNTIL.
COUNT.OVERLAPAllow overlapping substrings in COUNT() and COUNTS().
DEBUG.EQUATESCauses the definition of equate tokens referenced in a program to be saved in the object code when compiling in debug mode so that they can be used in the debugger.
DEFAULT.UNASS.ARGSEnables substitution of a default value for unassigned arguments in a SUBROUTINE or FUNCTION statement.
EXCEPTION.SAVE.STACKCauses the CATCH clause of a TRY/CATCH construct to behave as though the SAVING.STACK option is present.
EXECUTE.CLEARLISTClears the default select list prior to execution of the command in an EXECUTE statement.
EXPLICITIf enabled, all variables, including scalars, must be explicitly declared in a DIMENSION statement.
FOR.STORE.BEFORE.TESTStores the new value of the control variable in a FOR/NEXT construct before testing the end condition.
HEADING.NO.EJECTMakes the NO.EJECT mode of the QMBasic HEADING statement the default, suppressing the automatic page throw on setting a new heading.
IMPLIED.STOPThe QMBasic compiler normally inserts an implied RETURN at the end of a program, subroutine or function. Setting this option inserts an implied STOP for compatibility with other multivalue products. Class modules always insert a RETURN regardless of the setting of this option.
INDEX.OVERLAPAllow overlapping substrings in INDEX() and INDEXS().
NOCASE.STRINGSCompiles the program using case insensitive string operations.This directive must appear before any executable statements in the program source and applies to the entire program module. Selecting case insensitive string mode affects the relational operators (=, #, <, >, <=, >=), their multivalue function equivalents (EQS(), NES(), LTS(), GES(), LES(), GES()), the CHANGE(), CONVERT(), COUNT(), DCOUNT(), FIELD(), LAST(), INDEX() and SWAP() functions, the CONVERT, FIND, FINDSTR, GROUPSTORE and LOCATE statements and pattern matching.
NO.ECHO.DATASuppresses echo of data for INPUT if it is taken from the DATA queue. See also the NO.ECHO.DATA mode of the OPTION command.
NON.DURABLE.TXNMakes transaction commit non-durable such that nested transactions are inherited by the parent on commit.
NUMERIC.BOOLEANQM support for an internal Boolean data type was added at release 3.2-2 and the @FALSE and @TRUE tokens were modified to use this data type at release 3.3-0. Programs that use @FALSE or @TRUE compiled using release 3.3-0 or later will fail with a run-time error if executed on a release prior to 3.2-2. Use of the NUMERIC.BOOLEAN mode causes @FALSE and @TRUE to evaluate to 0 and 1 respectively for backward compatibility but may cause problems in programs that use data collections on later releases.
OPEN.FAIL.ZERO.FVARIf enabled, sets the file variable in an OPEN, OPENPATH or OPENSEQ to zero instead of unassigned if the open fails.
OPTIONAL.FINAL.ENDSuppresses the warning message if there is no END statement at the end of the program.
OPTIONAL.THEN.ELSEMakes the THEN/ELSE clauses of file read statements optional. The statements affected are MATREAD, MATREADL, MATREADU, READ, READBLK, READL, READU, READV, READVL and READVU.
PARTIAL.EXPRESSIONSCauses evaluation of a logical expression to terminate as soon as the result can be determined. See Partial Expression Evaluation for more details.
PICK.CONVERTPick style argument sequence for CONVERT()
PICK.ENTERPick style processing of ENTER.
PICK.ERRMSGPick style syntax for STOP and ABORT.
PICK.JUMP.RANGECauses the ON GOSUB and ON GOTO statements to continue at the next statement if the index value is out of range.
PICK.MATRIXCreate Pick style matrices. See the COMMON and DIMENSION statements for a discussion of the implications of this mode.
PICK.READCauses READ, READL, READU, READV, READVU and READVL statements to take on the Pick style behaviour in which the target variable is left unchanged if the record is not found.
PICK.READNEXTCauses the READNEXT statement to leave the record id variable unchanged when taking the ELSE clause.
PICK.SELECTChanges the behaviour of SELECTV (and SELECT when $MODE SELECTV is in effect) such that, if the default select list is active, that list is transferred into the target variable instead of building a new list.
PICK.SUBSTRCauses substring assignment operations to take on the Pick style behaviour in which the variable is extended by adding trailing spaces if the region to be overwritten is beyond the end of the current string value.
PICK.SUBSTR.ASSIGNCauses substring assignment operations to take on the full Pick style behaviour as described under Assignment Statements. Setting this mode overrides the PICK.SUBSTR mode.
PRCLOSE.DEFAULT.0PRINTER CLOSE defaults to printer 0 rather than closing all printers.
SELECTVChanges the action of SELECT to be as for SELECTV.
SSELECTVChanges the action of SSELECT to be as for SSELECTV.
STDFILEnables use of the default file variable.
STDFIL.SHAREDEnables use of the shared default file variable.
STRICT.EQUATEApplies strict rules to EQUATE token names and $DEFINE tokens, reporting a warning if the token name clashes with a reserved name, statement name or intrinsic function name.
STRING.LOCATENumeric data in right aligned LOCATE is not treated as a special case.
SYMTAB0Causes the compiler to emit the symbol table in the format used prior to release 4.0-0.
TIME.MSCauses the TIME() function and SYSTEM() with key 12 (SYS$TIME) to return the local time with a fractional (mS) part. This mode applies to the whole program regardless of where it appears.
TRAP.UNUSEDDisplays a warning about variables that are assigned a value but never used.
TRAP.UNUSED.MAINLike TRAP.UNUSED but warns only if the variable is assigned a value in the main body of the program rather than in an include record.
UNASSIGNED.COMMONVariables in common blocks are created unassigned instead of being initialised to zero.
UV.LOCATEUniVerse Ideal / Reality flavour style LOCATE.
WRITE.DELETE.THEN.ELSEWRITE, MATWRITE and DELETE statements have an optional THEN/ELSE clause.

 

Prefixing a mode name (other than DEFAULT) with a minus sign turns off the named option.

 

The $MODE directive allows use of shortcut names to enable multiple modes in a single step. Other modes that were already set when these are used will not be cleared. The shortcuts that give closest compatibility when migrating an application to QM are described under "Migrating to QM". The shortcut names below are retained from QM version 3.4-17 and earlier.

 

D3Sets CASE.SENSITIVE, CHANGE.NO.OVERLAP, COMPATIBLE.APPEND, COUNT.OVERLAP, FOR.STORE.BEFORE.TEST, HEADING.NO.EJECT, IMPLIED.STOP, INDEX.OVERLAP, OPTIONAL.FINAL.END, PICK.ENTER, PICK.ERRMSG, PICK.JUMP.RANGE, PICK.MATRIX, PICK.READ, PICK.SELECT, PICK.SUBSTR, PICK.SUBSTR.ASSIGN, SELECTV, SSELECTV, STDFIL, UNASSIGNED.COMMON, UV.LOCATE

 

MVBASESets CASE.SENSITIVE, CHANGE.NO.OVERLAP, COMPATIBLE.APPEND, COUNT.OVERLAP, FOR.STORE.BEFORE.TEST, HEADING.NO.EJECT, IMPLIED.STOP, INDEX.OVERLAP, OPTIONAL.FINAL.END, PICK.ENTER, PICK.ERRMSG, PICK.JUMP.RANGE, PICK.MATRIX, PICK.READ, PICK.SELECT, PICK.SUBSTR, PICK.SUBSTR.ASSIGN, SELECTV, SSELECTV, STDFIL, UNASSIGNED.COMMON, UV.LOCATE

 
The modes set by these shortcuts may change between releases.

 

Default modes can be set by creating a record named $BASIC.OPTIONS in the source file or in the VOC. Details of how to do this can be found with the description of the BASIC command.

 

Some of these modes can also be used in dictionary I-type expressions.

 

 

Examples

 

 

$MODE TRAP.UNUSED

FUNCTION INV.CLI(INV.REC)

  CLEINT.NO = INV.REC<4>

  IF CLIENT.NO = '' THEN CLIENT.NO = INV.REC<18>

  RETURN CLIENT.NO

END

 

The above program contains a typographical error in the spelling of the first use of CLIENT.NO. Because it has been compiled with the TRAP.UNUSED option, the compiler will display a warning message that the CLEINT.NO variable is assigned but never used.

 

 

PROGRAM INVOICE

FOR I = 1 TO 3

NEXT I

DISPLAY "I on exit = " : I

END

 

The above program displays the loop exit value as being 3 whereas the program below uses the FOR.STORE.BEFORE.TEST mode and displays the loop exit value as being 4.

 

$MODE FOR.STORE.BEFORE.TEST

PROGRAM INVOICE

FOR I = 1 TO 3

NEXT I

DISPLAY "I on exit = " : I

END

 

 

See also:

OPTION