GOSUB

Contents


"Gosub" is used to call a sub-programme at a given label.

Syntax

Gosublabel [Fromnom_trt]

Parameters

Element

Description

Restrictions

label

label may be preceded by the '$' character.

Must be defined in the routine.

nom_trt (1)
        (2)
        (3)
nom_d'OBJet
'=' expr_c
string

nom_d'OBJet

nom_d'OBJet indicating a routine

It must exist.

expr_c

Char type expression whose result is a string

string (1)
       (2)
       (3)
nom_d'OBJet
application"."nom_d'OBJet
absolute path of routine

 

Examples

# Management programme that may be called by Gosub GESTION_ZONES
 $GESTION_ZONES
Gosub INIT_ZONES
  While 1
     Gosub SAISIE_CHOIX
     Case [M]CHOIX
       When 'E' : Gosub EFFACE_ZONE
       When 'F' : Gosub FIN_GESTION : Return
       When 'M' : Gosub MODIF_ZONE
       When 'C' : Gosub CREER_ZONE
       When Default : Gosub ERREUR_CHOIX
    Endcase
  Wend
 Return
# The "SECUR" routine must be run from the first
 # reference application and no other
Gosub ETIQ From =adxmother(0)+".SECUR"

 

Description and comments

"Gosub" is used to call a sub-programme, that may or may not be defined in the same routine. This sub-programme will be identified by a label. Its execution stops when the "Return" instruction is executed, and it hands over again to the instruction following " Gosub".

The instructions are executed schematically in the following sequence (the figures in parentheses giving the sequence):

(1) Gosub ETIQUETTE

(2) $ETIQUETTE

(3) Sub-programme instructions

(4) Return

(5) Instructions AFTER Gosub
(6) End

 

Comments

A sub-programme called by "Gosub" must not end with an "End" but with an "Return".

 

Associated errors

Error

Description

PLUMEM (31)

More memory (may occur in the event of Gosub recursive).

ERRET (32)

Return not corresponding with a Gosub (happens on Return).

PAFIC (20)

the routine does not exist, or is inaccessible.

 

Associated keywords

SUBPROG - GOTO - RETURN - CALL


CONTENTS


Copyright © Sage 1999 - 2007