@Parameters
Declares the parameters of a Program or a Screen (full screen or Popup): one mode:&Variable entry per line. The type comes from the matching declaration in @Variables/global or @Variables/local, it isn’t repeated here.
| Mode | Description |
|---|---|
in | Input parameter: the caller passes a value, this program can’t return it modified. |
inout | Input/output: the caller passes a value, and this program can modify it back. |
out | Output: this program sets it, the caller only reads it back. |
@Variables {
global {
MyDate date
MyTime char(8)
}
}
@Parameters {
inout:&MyDate,
inout:&MyTime
}
Doesn’t apply to tables.
A Screen declares @Parameters just like a Program, with the same modes (in, inout, out). Parameters are available from Event Init, before the screen is displayed, and out/inout values return to the caller when the Screen closes.
Example: a Popup that receives a title, modifies a quantity and returns the chosen option (based on example/screens/SPOPPRM.warp).
@Properties {
Type : Screen
Popup : True
Name : SPOPPRM
Path : Screens
}
@Variables {
Global {
Title char(30)
Quantity number(5)
Selection char(1)
}
}
@Parameters {
in:&Title,
inout:&Quantity,
out:&Selection
}
Another Screen (or a Program) invokes it with Call, passing the variables in the same order; the analyzer validates count, type and mode:
@References {
Screens = [ "./SPOPPRM.warp" ]
}
@Source {
Event 'OpenPopup' 4
Call(SPOPPRM, &t, &n, &s)
If &s = "S"
&Result = "Accepted"
EndIf
EndEvent
}
List parameters
A @Parameters entry can be a list(char(n)) or a list(varchar(n)) (an array of text lines). It arrives as a dim(9999) array with no wrapper: in RPG, char(n) dim(9999), with const if the mode is in. Since the count is not passed, the program counts the lines up to the first empty line (or up to 9999) to set Count(). With out, the parameter starts as an empty list.
@Variables {
global {
Lines list(char(80))
}
}
@Parameters {
in:&Lines
}
Any other list (for example list(number) or list(struct(...))), or a matrix, gives E00304: only list of char or varchar is supported.
To send a list to another program: Call("PGM", &lines) or Call(Program, &lines) passes the dim(9999) array by reference (with the real signature if the program is in @References/Programs). The count is not sent: the receiver reads up to the first empty line, which is why the list removal operations truly clear the elements (see Data types: List).
Note: in a
Screen, a parameter used in@Layoutmust have more than 10 characters: with 10 or fewer it gives errorE00369, because the DDS field takes that same name and does not compile on IBM i.