Sie sind auf Seite 1von 28

I am functioning within established parameters.

- Lieutenant Commander Data

(But then, if you work in Synon you dont have a choice.)

VIRGIL GREEN

SYNAPTECH CONSULTING

What are parameters?


Primary vehicle for function communication in Synon Pervasive - even moving data from one field to another requires parameters Two types: Formal and Actual

Formal Parameters
Define interface for a function Control flow of data from function to function

Actual Parameters
Define values passed from one function to another Vary with each reference (call) to a function
VIRGIL GREEN 2 SYNAPTECH CONSULTING

Defining the formal parameter


Sets Passed As Entries Usage Role Error Flagging

- buckets of things (fields) - types and shapes of buckets - whats in the buckets? - do the things in the buckets bite? - if they bite can you get sick too? - if they dont bite, do they scream when you grab them?

VIRGIL GREEN

SYNAPTECH CONSULTING

Parameter Sets
Access by using P option on a function Up to 9 buckets (sets) can be used You can fill your bucket from

An Access Path A File Definition Any Field in the Model An *Array

Use each set or bucket for a particular Purpose For CRT/CHG/DLTOBJ functions, the first set must contain database fields for implicit *Move all to work
VIRGIL GREEN 4 SYNAPTECH CONSULTING

Function Parameters
EDIT FUNCTION PARAMETERS MRT development model Function name. . : Clc Schedule Priority Type : Execute external function Received by file : Nomination Array: *NONE Passed ? File/*FIELD Array as Seq *Arrays Clc Sched Priority PRM FLD *Arrays Clc Sched Priority PRM FLD *FIELD Count FLD *FIELD Save Array Index Y FLD *FIELD NLK Job Lock Level FLD *FIELD Job name FLD *FIELD User FLD *FIELD Job Number FLD | Values FLD: One parameter per field RCD: One parameter for all fields KEY: One parameter for key fields only SEL: Z-Details (field selection). F3=Exit F5=Reload

VIRGIL GREEN

SYNAPTECH CONSULTING

Understanding Passed As
Determines which fields from source are available Applies to a set and describes your bucket

RCD KEY FLD

- big buckets; sometimes hard to put things into - smaller, specialized buckets; still hard to fill - a bucket of buckets; only one thing to a bucket - required when using *Arrays, *Field, or *None access path

Does not affect internal functions FLD is recommended for external functions

VIRGIL GREEN 6 SYNAPTECH CONSULTING

RCD, KEY
and the External function
Causes a data structure to be passed which both caller and called must map internally Data structure is always the length of the entire key or record structure whether all fields are used or not Hex problems when numeric parameters are involved and program is called from command line, menu, or CL Entire structure passed as one physical parameter ...

A B C D E F G

... even if only these fields are used


VIRGIL GREEN 7 SYNAPTECH CONSULTING

FLD and the External function


Uses separate physical parameter for each defined parameter Allows greatest flexibility for calling from different sources

Only fields needed are passed as separate physical parameters

C
A E G Unwanted fields are ignored
VIRGIL GREEN 8

F
D

SYNAPTECH CONSULTING

Parameter Set Entries


Drawn from the list of fields identified by a set Any subset of fields in the set can be used Each field can have different role and usage but it is recommended that you standardize set usage When using *FIELD to declare the set there is only one entry for the set

VIRGIL GREEN

SYNAPTECH CONSULTING

Parameter Entries
EDIT FUNCTION PARAMETER DETAILS MRT development model Function name. . : Clc Schedule Priority Type : Execute external function Received by file : Nomination Array: Clc Sched Priority PRM Parameter (file) : *Arrays Passed as: FLD ? Field Usage Role Flag error Contract ID I NM Received Date I NM Received Time I Service Type Latest Eff Date for Nom Effective MDQ Remaining MDQ Distribute Zone Cap? Distribute Z-L Prty? Distribute Point Cap? Priority Level PT Path Type Tot Nom MMBtu Counter + SEL: Usage: I-Input, O-Output, B-Both, N-Neither, D-Drop. Role: R-Restrict, M-Map, V-Vary length, P-Position. Error: E-Flag Error. F3=Exit

VIRGIL GREEN

10

SYNAPTECH CONSULTING

Understanding Usage
Controls the direction of data flow on function calls Four different kinds of Usage:

Input Output Both Neither

- hears but cannot speak - speaks but cannot hear (may bite) - hears and speaks with aplomb - quiet and keeps to itself

VIRGIL GREEN

11

SYNAPTECH CONSULTING

Input
Finally, someone who will listen
For data coming into function Try to avoid using these to let the calling function direct processing in the called function Function should be able to perform based on data rather than external decisions Cannot be changed by function

VIRGIL GREEN

12

SYNAPTECH CONSULTING

Output
Just like a teenager, never listens
For data going out Function should guarantee that a value is set If on an external function, automatically initialized by the calling Synon function Cannot be referenced by function

Cannot be used as accumulator Cannot be passed to subordinate function

VIRGIL GREEN

13

SYNAPTECH CONSULTING

Both
Listens and jabbers, just like a talk show host
For data going in to be modified and then returned Avoid using as an accumulator since the data (total) is really going out, not in and out Reserve these for when data is being sent into a function explicitly to be modified in some way

VIRGIL GREEN

14

SYNAPTECH CONSULTING

Neither
Never swayed by the outside world
May be used as a local variable Good choice for accumulator; better than Both Allows reference and change but calling function cannot see it Can be passed to and received from subordinate functions but higher level functions cannot change or reference value Automatically initialized to blanks or zeros Not included in implicit *Move All from PAR to DB1

VIRGIL GREEN 15 SYNAPTECH CONSULTING

Tricky things about Usage

A field may not be used more than once unless it is used once for input and once for output
This is not recommended because the two parameters appear to be a single parm - either a both or a neither

Output parameters on create and change object functions are automatically loaded if the parameter is a database field Calling functions should take care to not use the same actual parameter for both an input and an output formal parameter

VIRGIL GREEN 16 SYNAPTECH CONSULTING

Understanding Role
Controls how the passed value of the parameter affects functions actions Five different roles:

None (or blank) Restrictor Positioner Mapped Vary

- leaves it just for you - gets you just what you ask for - always starting something - likes to pass the buck - used to let you break the rules

VIRGIL GREEN

17

SYNAPTECH CONSULTING

Restrictor
Keeps your function from running away
Any higher order keys must also be restrictors Limits set of data to be accessed by limiting to high order keys Used on all function types except messages, Excintfun, Excextfun, and Excusrsrc If high order key is also foreign key, causes relation to be validated before screen is displayed. Allows display of virtual fields without having them on the based-on access path

VIRGIL GREEN 18 SYNAPTECH CONSULTING

Positioner
A nice way to start something
Any higher order keys must be restrictors or positioners Allows you to start at a certain position in the index

processing starts at specified or next available item in index

There is nothing available to stop processing Used on Rtvobj, Prtfil, and Prtobj Multiple positioners allow starting point within multiple continuous variables

Start at first record after a given Date and Time


VIRGIL GREEN 19 SYNAPTECH CONSULTING

Mapped
Helps data find its way to the screen
Used only on *External functions with screens Moves data from parameter to screen field Places field on screen if not already there

In Control record for Edtfil, Edttrn, Dspfil, and Dsptrn In Detail record for Pmtrcd, Edtrcd, and Dsprcd Neither Mapped parms allow database fields that are not on based-on access path to be placed on screen

Initializes screen field with value


In Control, Subfile, and Detail record on all function types

VIRGIL GREEN

20

SYNAPTECH CONSULTING

Vary
Lets you get by with just about anything
Turns off domain checking but still requires character/numeric compatibility Not necessary since release 4.0, but recommended Only valid for Excusrsrc, Excusrpgm, Excextfun, and Error messages Allows easier integration with non-Synon programs Useful for including field value in generic error messages

VIRGIL GREEN 21 SYNAPTECH CONSULTING

Understanding Error Flagging


For Error Messages


Causes screen fields passed in to have error attribute set

For *External Functions


Causes screen fields passed in to have error attribute set if *Return code comes back not *Normal

By default error flagging is on Error checking prone to change can be externalized Turn off to include screen field in error message without turning on fields error attribute

VIRGIL GREEN 22 SYNAPTECH CONSULTING

How parameters are implemented

Passing by reference vs. passing by value


Passing by reference means that the field or data passed into the function are accessed and changed directly by the subordinate function Passing by value means that the original field or data is not directly accessed, but a copy is made into a temporary field which is then referenced or changed

Passing by value protects the data in the calling function from possible failures in called function which could leave a set of values partially changed
23 SYNAPTECH CONSULTING

VIRGIL GREEN

Parameters on *Internal functions


Passed by reference Called function has direct access to field passed into it Generated code actually uses field or constant passed in wherever the parameter is referenced Allows you to issue error messages from deep inside nested internal functions and still set error attributes on screen

VIRGIL GREEN

24

SYNAPTECH CONSULTING

Parameters on *External functions


Passed by value Actual AS/400 level implementation is pass by reference Synon shields us from AS/400 implementation by placing values in temporary variables when calling a program

VIRGIL GREEN

25

SYNAPTECH CONSULTING

Actual parameter defaulting


At generation time, Synon will attempt to default a context and field for any parameter on a called function for which a parameter has not been specified Allows use of fields other than keys for F4 prompt functions Can reduce maintenance time by not requiring a visit to every action diagram that calls a function whose parameters have changed Be cautious about relying on this; understand it first

VIRGIL GREEN 26 SYNAPTECH CONSULTING

What we would like to see


Local variables other than Neither parms Option to exit without save when mistakes are made Verification of value assignment Ignore feature to discard unwanted, returned values Expanded sets without having to use Arrays

VIRGIL GREEN

27

SYNAPTECH CONSULTING

Das könnte Ihnen auch gefallen