Introduction to statements

Statement format

A Synergy DBL statement is a single logical line of information and can be as long as 8192 characters of compilable text (excluding tabs and comments). Preceding and trailing blanks and tabs are ignored. We recommend that you adopt reasonable indentation conventions to make your programs as readable as possible; legibility simplifies all other aspects of program development and maintenance.

Continuation lines

Because it is impractical to work with lines that are longer than about 120 characters (80 on most CRT terminals), you’ll sometimes need to split a logical line into several shorter physical lines. The second and all subsequent parts of the statement line are called continuation lines, and their first nonblank character must be an ampersand (&).

The Synergy compiler treats a physical line and all continuation lines that follow it as one logical line. Therefore, you cannot insert any noncontinuation line—regardless of whether it is a blank line, a comment, a compiler directive, or anything else—between related continuation lines or between the first physical line and its continuation lines. A physical line cannot be longer than 255 characters (excluding line terminators, such as carriage returns and line feeds).

Blanks and tabs can precede the ampersand to improve readability. For example:

lbl02,
    val = "klh"         ;Transmitter
  &      "112385"       ;Package
  &      "txye1"        ;Destination
  &      "2b3"          ;Priority, class, level

can also be written as

lbl02,
    val = "klh"         ;Transmitter
        & "112385"      ;Package
        & "txye1"       ;Destination
        & "2b3"         ;Priority, class, level

Both statements are functionally identical to

lbl02,
    val = "klh112385txye12b3"

All characters that follow an ampersand are considered to be part of the statement. To avoid programming problems, be careful when splitting an alpha literal across a continuation boundary, and do not include comments inside a quoted string. If the opening delimiter for the literal is on one line and the closing delimiter is on the next, the contents of the literal resume immediately after the ampersand. For example, assuming there are no blank spaces or tabs at the end of each physical line, the following statement:

lbl02,
    val = "klh          ;Transmitter
           & 112385     ;Package
           & txye1      ;Destination
           & 2b3"       ;Priority, class, level

is equivalent to

lbl02,
    val = klh     ;Transmitter 112385  ;Package txye1   ;Destination 2b3

which is quite different from the result of the first two examples and probably not what you are looking for. See Alpha literals for further discussion.

Blank lines

Logical lines that consist entirely of blanks, tabs, or a comment are printed in the program listing but are otherwise ignored by the Synergy compiler. For example, the third line below is ignored:

lbl02,
    code = "klh"        ;Transmitter's code
    snum = "112385"     ;Package serial number
    dest = "txye1"      ;Destination ID

Comments

We highly recommend that you use numerous comments in your code to clarify what your program is doing, making it easier to maintain.

A comment begins with the first semicolon (;) that is not part of an alpha literal, and it continues to the end of the line. Comments are ignored by the compiler.

For example, in the following line of code, “;Initialize name” is a comment and is ignored by the compiler:

name = "John Doe"       ;Initialize name

Documentation comments

(Synergy .NET only) You can create documentation for your code by including XML tags as special comments in your source code directly preceding the code block they refer to. Such comments are supported for the following items: namespaces, classes, class fields, class groups, class records, generic classes, methods, constructors, destructors, main routines, functions, subroutines, properties, parameters, enumerations, nested structures, delegates, interfaces, and events. XML documentation comments placed anywhere else are ignored.

Documentation comments begin with three semicolons as the first characters on the line and extend to the end of the line. For example,

;;; <summary>
;;; Summary description for Class2
;;; </summary>
public class Class2

and

;;; <summary>
;;; Avg function description
;;; </summary>
;;; <param name="num1"></param>
;;; <param name="num2"></param>
;;; <returns></returns>
function avg, i, TRUNCATE
    num1        ,d.
    num2        ,d.
record
    rslt        ,i4

When you compile with the -doc option, the compiler searches for all XML tags in the source code and copies them line by line into an XML file. You can then use this generated file to create your code documentation using a third-party application of your choice (for example, Sandcastle).

Note

You can use any XML tags that are supported by the third-party application that you’ve selected. If the XML tags in your documentation comments are not well formed, you’ll get errors when that application processes the XML file.

Compound statements

A compound statement is a collection of simple statements preceded by a BEGIN and followed by an END. You can include a compound statement within a compound statement.

A compound statement is considered to be a single unit and can appear anywhere a single statement is allowed. Because they have multiple substatements, compound statements can improve the readability of your programs.

For example, consider the following sequence of statements:

    if (option .ne. SCAN) goto noscan
    find(chn, record, ^FIRST)
    start = 1
    if (.not. endflag) goto maxend
    display(TTCHN, "Maximum records to scan ")
    reads(TTCHN, input(1:^size(end)))
    end = input
    goto forloop
maxend,
    end = MAXRECS
forloop,
    for idx from start thru end
      xcall proc_rec(idx)
noscan,
  .
  .
  .

Compare the preceding code with the following code, which uses compound statements:

    if (option .eq. SCAN)
      begin
        find(chn, record, ^FIRST)
        start = 1
        if (endflag) then
          begin
            display(TTCHN, "Maximum records to scan")
            reads(TTCHN, input(1:^size(end)))
            end = input
          end
        else
          end = MAXRECS
        for idx from start thru end
          xcall proc_rec(idx)
      end

Data division

The data division is the section of a Synergy DBL routine in which you define most of the data that you will use in the procedure division of your program. The variables you define can be local to the routine or shared with other routines. Your field definitions are grouped into one or more of the following data structures: record, group, common, global data section, literal, class, or structure.

Here are some examples of data division statements:

global data section glb
    record rec1
      field1            ,a6,    "record"
      field2            ,d3.2
    endrecord
endglobal

global common rec2
    field3              ,a*,    "This is the initial value"
    field4              ,2d7
    field5              ,d4
     field5a              ,d2 @field5
     field5b              ,d2 @field5+2
endcommon
record rec3
    field6              ,a10
                        ,d4
    group grp1          ,a
       field7            ,d3,    542
       field8           ,d4
    endgroup
endrecord
public class class1
    public structure mystruct
        field9          ,i4
        field10         ,a20
    endstructure
endclass

Procedure division

The procedure division is the section of a Synergy DBL routine that follows the data division. It contains the executable statements of your program and defines the processing algorithms. It begins with the PROC statement and ends either at the physical end-of-file or at the END statement.

The operators and operands used in expressions within procedure division statements are documented in Expressions.