MAIN-ENDMAIN

Explicitly define a main routine

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
MAIN[ routine_name][, ROUND|TRUNCATE]
  .
  .
  .
[ENDMAIN]

Arguments

routine_name

(optional) The name of the main routine. (a)

ROUND

Use rounding rules for implied-decimal data types within the routine.

TRUNCATE

Use truncation rules for implied-decimal data types within the routine. (traditional Synergy only)

Discussion

The MAIN statement is recognized with or without a beginning period. You can specify only one MAIN statement within a program.

Routine_name will appear in compiler listing headers and runtime error messages. MAIN$ always precedes the resulting routine name, regardless of whether or not MAIN$ was specified as part of routine_name. The routine name is automatically uppercased.

The routine_name field is limited to 30 characters (or 31 on OpenVMS). If more characters are specified, an “Identifier too long” error (BIGIDEN) occurs. Those 30 characters may include MAIN$ in the first 5 characters followed by up to 25 more characters. If the routine_name field does not contain MAIN$ in the first 5 characters but is between 25 and 30 characters long, it is truncated without error to 25 characters.

If routine_name is omitted (or no explicit MAIN exists), the default routine name is MAIN$ followed by the first 25 characters (or 26 characters on OpenVMS) of the program’s source filename. In a multi-module compile, this is the first source file on the command line. (If the -t compiler option is being used, the default is MAIN$ followed by the first 6 characters of the source filename.) For example,

dbl file1 file2 main file3

will result in the main routine being named MAIN$FILE1.

The default message ID for the SEND and RECV statements is routine_name stripped of MAIN$. A message ID can have a maximum of 6 characters on Windows and UNIX or 39 characters on OpenVMS.

Here are some examples:

MAIN statement

Routine name

Default message ID

Windows/UNIX

OpenVMS

main avg

MAIN$AVG

AVG

AVG

main myaddressbookroutine

MAIN$MYADDRESSBOOKROUTINE

MYADDR

MYADDRESSBOOKROUTINE

main main$contact

MAIN$CONTACT

CONTAC

CONTACT

main

MAIN$source, where source is the first 25 characters of the program’s source filename

The first 6 characters of the program’s source filename

The first 39 characters of the program’s source filename

A program by default rounds all expression results. You can change the default to truncate in traditional Synergy by setting system option #11. However, specifying the ROUND or TRUNCATE modifier on a MAIN statement overrides the default rounding behavior for that routine (including if system option #11 is set). You cannot specify both TRUNCATE and ROUND in the same directive. (Neither TRUNCATE nor system option#11 are supported in Synergy .NET.)

Examples

In this example, orders is the name of the main routine. Since ­TRUNCATE is specified, var is assigned 3. If ROUND were specified (or if no modifier were specified), var would be assigned 4.

main orders, TRUNCATE
record
    var   ,d3
proc

    .
    .
    .
    var = 3.5

    .
    .
    .
endmain