HP 3000 Manuals

##returnvalue [ VIRTUOSO CODE GENERATOR Reference Manual ] MPE/iX 5.0 Documentation


VIRTUOSO CODE GENERATOR Reference Manual

#returnvalue 

Assigns a value to a keyword in the previous scope.

Syntax 

     #returnvalue keyword=value 

Keywords 

keyword          is the keyword to be assigned a value in the previous
                 scope.  The keyword must conform to the naming
                 restrictions.

value            is the value to be assigned to a keyword.  This can be a
                 literal value or a keyword value.

Description 

The #returnvalue construct assigns a value to a keyword in the previous
scope.  The keyword that is assigned a value does not have to exist in
the previous If the keyword does exist in the previous scope, its value
is modified.  When the keyword does not exist, the keyword is introduced
in the previous scope with the specified value.

After you assign a value to a keyword, the value can be accessed by
referencing the name of the keyword preceded by the substitution
character.  This construct is useful for returning values from macros,
from within a #for/#endfor scope, or from within a #block/#endblock
scope.  If you are at the highest scope (that is, no previous scope
exists), then using #returnvalue produces an error.

Examples 

EXAMPLE 1

     #macro GetDatasetRecord image-dataset=string seqno=(numeric,1)
     #
     #getrel image-dataset="!image-dataset" record=?   &
     #       relclass="contains"                       &
     #       seqno=!seqno
     #
     #if numrels > 0
     #   returnvalue record="!record"
     #else
      .
      .
     #endif

This example illustrates using the #returnvalue construct to return a
keyword value from a macro.  The keyword record, whose value is the name
of the image-dataset record, is installed in the scope of the model or
macro that invoked the GetDatasetRecord macro.  That is, the keyword is
created if it does not exist, and overwritten with the new value if it
does exist.  This allows the caller to access the value of the keyword
record.

     EXAMPLE 2

     #macro GetPrimarySearchElement record=string          &
     #                    image-dataset=string             &
     #                    image-database=string
     #
     #let image-item=" "
     #for image-dataset="!image-dataset" element=? element=?   &
     #    image-dataset=? image-database="!image-database"     &
     #    relclass="chains" attr=(primary-flag)
     #
     #    if primary-flag = "TRUE"
     #       returnvalue image-item = "!element:1"
     #    endif
     #
     #endfor
     #
     #returnvalue search-item="!image-item"
     #endmacro

The above example illustrates using the #returnvalue from within a
#for/#endfor loop.  Since this is a scope below that of the macro, a
second #returnvalue is used to return the search-item name to the scope
of the model or macro that invoked the GetPrimarySearchElement macro.



MPE/iX 5.0 Documentation