Applies To:
  • CitectSCADA

How do you pass multiple arguments from a Citect VBA procedure to a Cicode function using CicodeCallOpen()? Does this work with different types of variables? 

CicodeCallOpen() allows you to pass any number of arguments to a Cicode function. For example:

CicodeCallOpen "TrnSetScale", 53, -1, 100, 32000

As with any Citect VBA function, all the arguments must be enclosed in parentheses if a return value is required.

blnSuccess = CicodeCallOpen("TrnSetScale", 53, -1, 100, 32000)

It is also possible to pass Citect VBA variables to the Cicode function. The data types will automatically be converted if possible. Since Cicode doesn't support passing by reference, though, you must put parentheses around each variable name to force it to be passed by value:

blnSuccess = CicodeCallOpen("TrnSetScale", (intAN), -1, 100, (intMaxScale))

Without the parentheses, the variables would be passed as 0 (or a blank string for String variables). At this time, it is not possible to pass variable tags with CicodeCallOpen(). You will have to copy the tag values into Citect VBA variables first. For example, if a variable tag named MAX_SCALE contained the scale value, this code could be used:

Dim intMaxScale As Integer
intMaxScale = MAX_SCALE
blnSuccess = CicodeCallOpen("TrnSetScale", (intAN), -1, 100, (intMaxScale))

Note: Boolean type variables will be passed to Cicode as -1 for TRUE or 0 for FALSE.