^VAL

Pass an argument by value or declare a value type function

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
^VAL(expression)

or

^VAL(argument)          ,i

or

external function
    funcname    ,^VAL
    .
    .
    .
function funcname       ,^VAL[(i)]

Arguments

expression

An argument to pass by value. (n)

argument

An argument of type i passed by value. (i)

funcname

The name of the function being declared. (a)

Discussion

^VAL is used to pass an argument by value, to declare an argument as type value, or to declare a function as returning an int by value.

^VAL can be used to pass arguments to C routines. If you use ^VAL to pass arguments to Synergy DBL routines, the corresponding parameters in the Synergy routines must be declared as type ^VAL, with an integer data type. When an argument is passed by value, the binary representation of the result of expression is passed.

Functions declared as type ^VAL are “true” functions with integer return values. If the value specified in the function’s FRETURN statement is not integer data type, it is converted to integer.

On OpenVMS, any routine that passes floating-point arguments by value will not work on either Alpha or I64. This type of routine requires a C wrapper routine.

See also

Examples

This example shows a call to a ^VAL function in which some arguments are passed by value.

.include "$DVIDEF" library "DBLSTARLET"
external function
    sys$getdviw         ,^val
record
    stat                ,i4
    group itmlst        ,[4]i
      len               ,i2
      code              ,i2
      bufaddr           ,i4
      retlen            ,i4
    endgroup
    mbx_syschan         ,i2
    mbx_name            ,a16
proc
    open(1, o, "tt:")
    xcall crembx(2, "message_mbx", 0, 132, 1320,,, 1) ;Create mailbox
    itmlst[1].len = ^size(mbx_name)                   ;Set up item list
    itmlst[1].code = DVI$_DEVNAM
    itmlst[1].bufaddr = ^addr(mbx_name)
    itmlst[1].retlen = 0
    clear itmlst[2].len, itmlst[2].code
    xcall getfa(2, "SCH", mbx_syschan)              ;Get mailbox channel
    stat = %sys$getdviw(, ^val(mbx_syschan),, ^ref(itmlst),,,,)
                                                    ;Pass args by value and ref
    if (.not. (stat .band. 1))
      xcall lib$stop(^val(stat))
    writes(1, "Mailbox name: " + mbx_name)        ;Get device name of mailbox
                                                  ; directly into the send msg
end