basic.subroutine Statement/BASIC Program

basic.subroutine

Command basic.subroutine Statement/BASIC Program
Applicable release versions: AP, R83
Category BASIC Program (486)
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.
Syntax subroutine {(argument.list)} subroutine subroutine.name{(argument.list)}
Options
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).
Purpose
Related basic.statements
basic.enter
basic.precision
basic.clear
hotkey0
hotkey1
hotkey2
hotkey3
hotkey4
hotkey5
hotkey6
hotkey7
hotkey8
hotkey9
tcl.date.iconv
basic.call
basic.return
up.x0
up.x1
up.x2
up.x3
up.x4
up.x5
up.x6
up.x7
up.x8
up.x9
basic.common
basic.access
basic.gosub