^VARARGARRAY

Access and pass VARARGS undeclared arguments

 

WNSupported in Synergy .NET on Windows

 

 

array = ^VARARGARRAY

or

^VARARGARRAY(array)

Arguments

array

A dynamic array of VariantDesc. VariantDesc is the base type in the Synergy .NET runtime for traditional Synergy data types. A variable defined as VariantDesc can be assigned to/from any descriptor type. See Understanding .NET data types for a list of descriptor types.

Discussion

In traditional Synergy, the Synergy routine call block API can be used to dynamically generate routine calls at runtime, rather than at compile time. In Synergy .NET, the ^VARARGARRAY data reference operation, together with the VARARGS routine modifier and the XSUBR routine, can be used to achieve similar functionality.

The VARARGS routine modifier enables you to pass more than the declared number of arguments, which means that the number of arguments passed can change based on changing conditions in your program.

The ^VARARGARRAY data reference operation enables you to access the hidden trailing optional arguments in a VARARGS routine. For example,

subroutine myroutine, varargs
    My1stArg            ,n
record
    MyVarArgs           ,[#]@VariantDesc
    NewVarArgs          ,[#]@VariantDesc

The local array (myVarArgs) could then be manipulated using the methods defined for the System.Array class in .NET, or more likely, you would add, modify, or remove elements as you copied them to a new array (newVarArgs). This array could then be passed to another routine, thereby dynamically defining the parameters. For example,

xcall yourRoutine(arg1, arg2, ^varargarray(NewVarArgs))

or

xcall xsubr(“yourRoutine”, arg1, arg2, ^varargarray(NewVarArgs)) 

You can also use ^VARARGARRAY to pass on the hidden trailing optional arguments to another VARARGS routine’s hidden parameter array. For example,

xcall hisRoutine(arg1, ^varargarray)

If you are dynamically constructing calls to system-supplied routines in .NET, ^VARARGARRAY can only be specified in place of documented repeating arguments (e.g., argument[,…] or [argument,…]) that occur after the last declared argument. The table below contains a list of the Synergy routines that accept a ^VARARGARRAY argument and the number of declared arguments in each routine:

Declared Arguments for Routines that Accept ^VARARGARRAY

Routine

Number of arguments

xcall ISAMC(file_spec, rec_size, num_keys, key_spec[, ...])

4

xcall S_BLD(destination, length, control[, argument, ...])

3

value = %SSC_BIND(dbchannel, dbcursor, numvars, var[, ...])

3

value = %SSC_CLOSE(dbchannel, dbcursor[, ...])

2

value = %SSC_DEFINE(dbchannel, dbcursor, numvars, var[, ...])

3

value = %SSC_EXECIO(dbchannel, dbcursor, [ncount], [numvars][, type, var, arg]
[, ...]
)

4

value = %SSC_OPEN(dbchannel, dbcursor, statement, type, [options], [numvars]
[, var, ...]
)

6

value = %SSC_SCLOSE(dbchannel, dbcursor[, ...])

2

value = %SSC_SQLLINK(dbchannel, dbcursor, statement[, numvars][, var, ...])

4

xcall W_AREA(id, function[, ...])

1

xcall W_BRDR(id, function[, ...])

2

xcall W_DISP(id, function[, ...])

2

xcall W_FLDS(id, function[, ...])

2

xcall W_INFO(function[, ...])

1

xcall W_PROC(function[, ...])

1

return = %WPR_EXECUTE(report_handle, operation[, arguments])

2

return = %WPR_INFO(report_handle, operation[, arguments])

2

return = %WPR_PRINT(report_handle, operation[, arguments])

2

xcall XSUBR(subroutine[, arguments, …])

or

value = %XSUBR(valfunction[, arguments, ...])

1

xcall XSUBR(nonvalfunction, return[, arguments, ...])

2