basic.statements

Definition/BASIC Program, Releases: AP and R83

Definition of statements and functions.

Description

differences between statements and functions in Pick/BASIC, a working definition of variable, constant, labels, blanks, and program formatting.

If the syntax requires that the instruction be followed by a set of parentheses (optionally containing an argument or arguments), then it is a function. For example, the following are functions: 'abs(num.expression)', 'rnd(num.expression)' and 'iconv(string.expression, conv.expression)'.

Any instruction that does not have to be followed by a set of parentheses is most often a statement. For example: 'print x', 'input y', 'execute sentence'.

There is at least one peculiar exception to the above rule. One variant of the 'locate' statement is considered a statement, even though its syntax looks like it should be a function.

Another feature of statements is that they tend to 'stand alone'. For instance: 'execute sentence' or 'print array<10,1>'.

Functions, by contrast, do not stand alone. They are either used as part of an expression within a statement: 'raise = rnd(20)', or output immediately: 'crt int(amount)', 'print abs(balance)'.

A Pick/BASIC program is composed of statements made up of Pick/BASIC commands, variables, constants, expressions, and functions.

Pick/BASIC statements may contain arithmetic, relational, and logical expressions. These expressions are formed by combining specific operators with variables, constants, or Pick/BASIC intrinsic functions.

The value of a variable may change dynamically throughout the execution of a program. A constant, as its name implies, has the same value throughout the execution of a program.

An intrinsic function performs a pre-defined operation on the supplied parameter(s).

Normally, within a Pick/BASIC program, each physical line contains only one statement. This is done for ease of reading and tracking of logic.

More than one statement may be placed on a program line by separating each statement with a ';' (semicolon). Statements which end with 'then' or 'else' on a line create a block or multi-line structure. See the 'if' statement for details on 'then...else' statements.

Labels may be placed at the beginning of any Pick/BASIC statement. A statement label may be numeric or alphanumeric. See 'statement labels'.

Blank spaces appearing in the program line which are not part of a literal are ignored. Blank spaces and blank lines may be used freely within the program for purposes of appearance. (AP only -- R83 does not support blank source lines).

See Also

Command Name Type Description
basic.string.expression Definition An expression which evaluates to a string.
basic.num.expression Definition An expression which evaluates to a number.
basic.cos Function Returns cosine of numeric expression.
basic.assigned Function Determines if variable has been assigned a value.
basic.case Statement Initiates the case statement.
basic.clear Statement Initializes all variables.
basic.col1 Function Returns beginning position derived from last 'field' function.
basic.col2 Function Returns ending position derived from last field function.
basic.convert Statement Converts characters.
basic.crt Statement Outputs expression to crt.
basic.debug Statement Invokes Pick/BASIC debugger.
basic.delete.statement Statement Deletes item from file.
basic.dim Statement Declares a dimensioned array.
basic.echo Statement Toggles terminal echo.
basic.enter Statement Transfers control to cataloged program.
basic.execute Statement Performs TCL command expression.
basic.include Statement Includes object module within object module.
basic.index Function Returns numeric starting position of string within string.
basic.inputtrap.gosub Statement Sets trap for input@ statement subroutine branches.
basic.inputtrap.goto Statement Sets trap for input@ statement subroutine branches.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.