basic.subroutine

Statement/BASIC Program, Releases: AP and R83

Defines program as external subroutine.

Syntax

subroutine {(argument.list)} subroutine subroutine.name{(argument.list)}

Description

defines program as an external subroutine.

Pick/BASIC provides the ability to 'call subroutines'. The 'subroutine' statement must appear on the first line of an external subroutine invoked by a 'call' statement.

Arguments defined in the optional 'argument.list' are delimited by ',' (commas). The 'argument.list' must have the same number of arguments as are in the 'call' statement.

If a subroutine is called from the Update processor, in either a file-defining item, or an attribute-defining item, no 'argument.list' may be specified by the 'call' statement. If called from a file-defining item, the 'item' being filed is automatically passed as a parameter in a call. If called from an attribute-defining item, the current value of the attribute being processed is automatically passed. Note that the subroutine will be called once for every value in the attribute.

A subroutine exits with a 'return' statement.

All external subroutines must be cataloged prior to execution.

Example

*program main
10 input start.date
call validate.date(start.date,ok)
if not(ok) then goto 10

This example prompts for a date and calls the external subroutine
'validate.date' to make sure the date is legal. Here is the
subroutine:

subroutine validate.date(pdate,ok)
* may need rework for years crossing 2000
if pdate matches '1n0n1x1n0n1x2n0n' then
if iconv(pdate,'d') # '' then
ok=1
end else
ok=0
end
end else
ok=0
end
return

The variable 'ok' is set to 1 if the date is valid. Otherwise,
'ok' is set to zero (false).

See Also

Command Name Type Description
basic.statements Definition Definition of statements and functions.
basic.enter Statement Transfers control to cataloged program.
basic.precision Statement Defines precision for calculations.
basic.clear Statement Initializes all variables.
hotkey0 Attribute Defining Item Hotkey to call Pick/BASIC subroutine.
hotkey1 Attribute Defining Item Hotkey to call Pick/BASIC subroutine.
hotkey2 Attribute Defining Item Hotkey to call Pick/BASIC subroutine.
hotkey3 Attribute Defining Item Hotkey to call Pick/BASIC subroutine.
hotkey4 Attribute Defining Item Hotkey to call Pick/BASIC subroutine.
hotkey5 Attribute Defining Item Hotkey to call Pick/BASIC subroutine.
hotkey6 Attribute Defining Item Hotkey to call Pick/BASIC subroutine.
hotkey7 Attribute Defining Item Hotkey to call Pick/BASIC subroutine.
hotkey8 Attribute Defining Item Hotkey to call Pick/BASIC subroutine.
hotkey9 Attribute Defining Item Hotkey to call Pick/BASIC subroutine.
tcl.date.iconv Subroutine Calls external subroutine to iconv date argument.
basic.call Statement Calls external Pick/BASIC subroutine.
basic.return Statement Returns control from a local or external subroutine.
up.x0 Command Invokes a subroutine called from the dictionary attribute 'hotkey0'.
up.x1 Command Invokes a subroutine called from the dictionary attribute 'hotkey1'.
up.x2 Command Invokes a subroutine called from the dictionary attribute 'hotkey2'.

User Comments

What do you think?

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

Login to leave your comments.