8. Using Vision Advanced Features : Passing Parameters Between Frames : Guidelines for Passing Parameters
 
Share this page                  
Guidelines for Passing Parameters
Follow these rules and guidelines when passing values between frames:
You can pass parameters from Menu, Append, Browse, or Update frames only (because these are the only frames that can have children in a Vision application).
The fields between which you pass the parameters can be either hidden or displayed.
The parameter must be in the form of one of these values from the parent frame:
The name of a field on the form
A hidden field
This can be either a local or global variable. Creating local and global variables is discussed later in this chapter.
An expression
The discussion of expressions in Using Expressions in Frame Definitions also applies to parameters. For more comprehensive information on expressions, see the 4GL part of this guide.
A database query
For example, passing the following parameter from the parent frame:
select name from customers
where customer_no = :customer_no
displays on the child frame the name of the customer whose customer number appears on the parent frame.
See the 4GL reference part of this guide for more information about passing queries between frames.
A local procedure
Use a local procedure as a parameter when the return value of the procedure is the correct data type to pass as a parameter. For example, if you have a procedure "myproc" that returns an integer value, specifying the parameter:
myproc()
passes the integer value to the child frame.
Local procedures are discussed in more detail in Using Local Procedures.
Be sure that the values on the parent and child frames have consistent data types.
For example, you cannot pass a value from an integer field into a character field. If Vision cannot pass a parameter, you get a runtime error when you call the child frame.
Vision passes parameters by value as the default method.
A parameter passed by value is not affected by any changes made to the value on the child frame. For example, if you pass a parameter with a value of 2 and then change that value to 4 on the called frame, the value still is 2 on the calling frame when you return to it.
You also can pass a parameter by reference. A parameter passed by reference is changed in the calling frame if its value is changed in the called frame. In the example above, the value on the calling frame is 4 when you return to it.
To pass a parameter by reference, include the keyword byref before the specification of the value from the parent frame. For example:
byref (quantity)
You cannot pass a global variable as a parameter by reference.
The value that you want to pass must be current for the parent frame. If the value is removed—for example, by clearing the form or saving it to the database—it is not passed to the child frame.
To pass parameters from a parent frame to any number of its child frames, you must specify the parameter separately for each child to which it is to be passed.
You cannot pass a value from a simple field to a column in a table field. If Vision cannot pass a parameter, you get a runtime error when you call the child frame.