Program Structure

The structure of an ASB program is rather loose, consisting of one or more lines satisfying the following syntax:

{line #}{label:}{statement} {! comment}

Line numbers can be used as labels, for the purpose of GOTO or GOSUB calls, but are typically deprecated in modern usage. Labels can also be used as the target of a GOTO or GOSUB statement, but in modern usage are mostly limited to aesthetic or code clarification purposes.

Statements are terminated implicitly by the end of the source text line (LF or CRLF), or explicitly by the comment character "!".  To extend a logical statement over multiple source text lines, use the "&" character to indication continuation, e.g.

statement'syntax$ = lineno$      &

                    + label$     &  ! optional comment may follow "&"

                    + statement$    ! another comment

 

As shown in the example above, comments may follow the & continuation character without interfering with the continuation. However, be careful about ending a comment with the & continuation character, since it effectively extends the comment to the next line. For example, in the following, the "print b" statement will become part of the comment at the end of the previous line, due it it ending in & ...

print a    ! don't end a comment with &

print b    ! else following line (this one) will be part of comment

 

Multiple statements may also be combined on a single source text line by separating them with a colon, e.g.

if SWAP then &

    V1 = V1+V2 : V2 = V1-V2 : V1 = V1-V2    ! 3 statements on a line

 

Note that while the above form is typical in older code, the style—if without endif, continuation, multiple statements per line—like the archaic verb "LET", is generally deprecated now in favor of the more readable:

if SWAP then

    V1 = V1 + V2

    V2 = V1 - V2

    V1 = V1 - V2

endif

 

Statements fall into the following categories:

• Declaration of Variables

Control Structures

Compiler Directives

User-Defined Functions and Procedures

Assignment Statements

I/O Statements

• Miscellaneous Statements