CALL |
"call" allows you to call a subroutine being executed with its own local variables with return to the calling process. Parameters can be passed.
SYNTAX 1Callsubrout ['('arg_list')'] [Fromprocess]
SYNTAX 2Callsubrout [With '('arg_list')'] [Fromprocess]
|
Element |
Description |
Restrictions |
|
subrout |
Subroutine defined in the
following formats: |
Must correspond to a subroutine in the corresponding process |
|
prgname_exp |
Expression of the Char type which results in a subroutine name |
If you have parameters, use syntax 2. |
|
process |
Process in which the
subroutine (it is the current process by default) is defined in one of the
following formats: |
The process must be accessible. |
|
prcname_exp |
Expression of the Char type which results in a process name |
The process must be accessible. |
|
arg_list |
List of parameters separated by the comma (,) These parameters can be variables or expressions. |
None |
# Call of a sequence number incrementation subroutine in the# TRTCPT Process In this instruction, pass a parameter by# its value. The corresponding parameter of the INCR_CPT subroutine# must be declared with the Value mode.Call INCR_CPT(10)
# A bit further in the same process...
INCR_CPT(DELTA) SubroutDELTA Integer ValueTrbeginLock SEQUENCE NUMBER With lockwait = 5If fstat: Rollback: End: Endif[C]SEQUENCE NUMBER += DELTACommit # Call of a subroutine without parameters in another process# from the first reference application.Call INCR1_CPT From = adxmother(0)+".TRTCPT"
# Call of a subroutine with parameters# The name of the subroutine is stored in the WWPROG variable.# It is therefore necessary to use syntax 2.If [F:AMA]ACTION="SPE": WWTRT = [F:AMK]TRTSPE: EndifIf [F:AMA]ACTION="STD": WWTRT = [F:AMK]TRTSTD: EndifWWPROG = "AV_"+[F:AMZ]CODZONCall =WWPROG With VALUE From =WWTRT
"call" launches a subroutine with eventual passing of parameters. At the end of this execution, the calling process uses its execution with the instruction after the "call" instruction, since the variables local to the subroutine and OBJects opened by lui in Local mode are closed.
When the "call" call is performed without specifying a process, the subroutine must be found in the process itself.
The parameters passed in the "call" must be equal in number to those of the subroutine. The order of the parameters in "call" is the same as those of the subroutine (Subprog).
These parameters may be variables or expressions. If it is an expression, its passing must be performed by value; the Subprog parameter cannot be sized.
A variable passed in parameters can be sized. It must then have the same dimension as the corresponding variable of the Subprog. .
For example: Take a table of integers with 2 dimensions
declared by:
Integer T2(I1..I2,J1..J2)
With I1 <= I11 <= I21 <= I2 and J1 <= J11 <= J21 <= J2
If you perform Call SUBPRG( T2 ), you will pass
the entire table.
It is the same if you perform Call SUBPRG( T2(I1..I2,J1..J2))
If you perform Call SUBPRG( T2(I11,J1..J2)), you will only pass one
"line."
If you perform Call SUBPRG( T2(I1..I2,J11)), one "column."
If you perform Call SUBPRG( T2(I11,J11), a single "element".
if you perform Call SUBPRG( T2(I11..I21,J1..J2)), several "lines"
, etc.
During a "call", the following information is saved:
· Global Variables
· The files and open screens as much in "global" mode as in Local, with the current values of the corresponding [F], [G], and [M] classes.
· The dialog boxes open as much in "global" mode as in Local
· The group of the default class lists (outside of any local class)
· The fact of being in Inter or Nointer mode
On the other hand, the following are lost:
· The files, screens, and dialog boxes open in Local mode and reopened with the same abbreviation in the subroutine.
·
The label associated with Onerrgo is not saved when passing to a
subroutine - even if this is performed in the same process; on the other hand,
this information is found in the calling process after executing the "call."
It is the same with the label associated with Onintgo.
When executing a "call," a class of local variables is created with the subroutine, abbreviated [L]. This local class becomes the default class, since the local class with the calling process is no longer accessible. When you return to the process, you will find the default local class, which existed before the call.
When executing a "call," if you modify the default classes, screens, open files, or dialog boxes, it is imperative to use the Local Mask, Local File, or Local ...Box instructions. The Mask, File and ...Box instructions affect open OBJects, which causes problems when you return from the "call."
A "call" can be called recursively, the number of embedded "calls" is not limited, but you will have to pay attention to the available memory, the number of open OBJects, and - in particular - the number of files open in Local mode as each subroutine is viewed as independent. For example:
Close File: adxmto = 10: Call SBPRG
# With
Subprog SBPRG
Local File FIC1: Call SBPRG: End
# After 10 calls, a TROPFIC error will stop this process.
|
Error |
Description |
|
PAFIC (20) |
Process does not exist |
|
ERDIM (55) |
Number of dimensions invalid |
|
ERARGNO (69) |
Number of parameters declared in Subprog that does not correspond to the number passed in Call |
|
ERARGTY (70) |
Passing mode incompatible |
|
ERLAB (39) |
Subroutine does not exist |
|
ERMODE (10) |
prcname_exp is not a character string |
SUBPROG - END - GOSUB - CONST - VALUE - VARIABLE - MASK - FILE - INPBOX - ONERRGO - ONINTGO - TRBEGIN - ADXPNO
|
|