Function Call (@)

Purpose

Invokes a FUNCTION block, MACRO_FUNCTION block, or built-in function with specified arguments. If the function is not a built-in function, you must define it in the Net.Data macro before you specify a function call.

Syntax

>>-@function_name---(------------------------------------------->
 
>-----+-----------------------------------------------+--)-----><
      |  .-,----------------------------------------. |
      |  V                                          | |
      '----+-variable_name-----------------------+--+-'
           +-variable reference------------------+
           +-function call-----------------------+
           |    .-------------------------.      |
           |    V                         |      |
           '-"----+-string-------------+--+---"--'
                  +-variable reference-+
                  '-function call------'
 

Values

@function_name
The name of any existing function. An alphabetic or numeric string that begins with an alphabetic character or underscore and contains any combination of alphabetic, numeric, or underscore characters.

variable name
A name that identifies a variable. See Variable Name for syntax information.

string
Any sequence of alphabetic and numeric characters and punctuation, except the new-line character.

variable reference
Returns the value of a variable and is specified with $ and (). For example: if VAR='abc', then $(VAR) returns the value 'abc'. See Variable Reference for syntax information.

function call
Invokes one or more FUNCTION or MACRO_FUNCTION blocks, or a Net.Data built-in function with specified arguments.

Context

Function calls can be found in these contexts:

Restrictions

Examples

Example 1: A call to the SQL function formQuery

%FUNCTION(DTW_SQL) formQuery(){
SELECT $(queryVal) from $(tableName)
%}
 
%HTML (input){
<p>Which columns of $(tableName) do you want to see?</p>
<form method="post" action="report">
<input name="queryval" type="checkbox" value="name" />Name
<input name="queryval" type="checkbox" value="mail" />E-mail
<input name="queryval" type="checkbox" value="fax" />FAX
<input type="submit" value="submit request" />
</form>
%}
 
%HTML (report){
<p>Here are the columns you selected:
<hr>@formQuery()
%}

Example 2: A call to a REXX function with input and output parameters

%FUNCTION(DTW_REXX) my_rexx_pgm(INOUT a, b, IN c, OUT d) {
 %EXEC{ mypgm.cmd this is a test %}
%}
%HTML(INPUT) {
 <p> Original variable values: $(w) $(x) $(z)
 <p> @my_rexx_pgm(w, x, y, z)
 <p> Modified variable values: $(w) $(x) $(z)
%}

Example 3: A call to a REXX function, with input parameters, that uses variable references and function calls

%FUNCTION(DTW_REXX) my_rexx_pgm(IN a, b, c, d, OUT e) {
  ...
%}
%HTML(INPUT) {
 <p>  @my_rexx_pgm($(myA), @getB(), @retrieveC(), $(myD), myE)
%} 

Example 4: A macro that illustrates the use of the INOUT parameter.


%DEFINE a = "initial value of a"


%FUNCTION(DTW_REXX) func1(INOUT x) {
Say 'value at start of function:<br />
Say 'x =' x
Say '<p>'
x = "new value of a"
%REPORT {
<p>value at start of report block:<br />
x = $(x)<br />
@dtw_assign(x, "newest value of a")
value at end of report block:<br />
x = $(x)<br />
%}
%}
%HTML(report) {
initial values:<br />
a = $(a)<br />
@func1(a)
value after function call:<br />
a = $(a)<br />
%}

Resulting output:

initial values:
a = initial value of a
 
value at start of function:
x = initial value of a 
 
value at start of report block:
x = new value of a
 
value at end of report block:
x = newest value of a
 
value after function call:
a = newest value of a
 


[ Top of Page | Previous Page | Next Page | Index ]