Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

CicodeCallOpen

  • Last UpdatedJul 18, 2023
  • 3 minute read

The CicodeCallOpen function is used to call a Cicode function from VBA. It is used to initiate and execute a call to the Cicode function and returns an integer value representing either an error code or the success of this VBA function making the call.

Note: This VBA function does not return the actual return-value of the Cicode function being called. You can obtain that return value by using the associated CicodeCallReturn function.

UNINTENDED EQUIPMENT OPERATION

Do not nest the CicodeCallOpen and CicodeCallReturn functions. Nesting these functions can lead to unintended equipment operation when your program is run.

Failure to follow these instructions can result in death, serious injury, or equipment damage.

For details, see Calling Cicode from VBA in the topic Using VBA in Command or Expression Fields.

Syntax

ReturnValue = CicodeCallOpen(FunctName, ArgList)

ReturnValue:

The return value for the function in the range of 0 to 3.

FunctName:

The name of the Cicode function being called.

Arglist:

A variable length comma separated argument list of all the arguments to be passed to the Cicode function being opened (dependant upon which Cicode function is being called and the arguments that Cicode function requires). The argument list should not be enclosed within brackets, although when using variable names as arguments, those variable arguments within the list need to be individually enclosed within brackets to force the passing of the variable to Cicode by value.

Return Value

CicodeCallOpen returns a integer data type containing a value in the range of 0 to 3:

  • 0 if CicodeCallOpenfunction was successful

  • 1 for CicodeCallOpenfunction general error

  • 2 for specified Cicode function not found

  • 3 for incorrect number of arguments for specified Cicode function passed in <ArgList>.

CicodeCallReturn

Example

In the following example, a VBA variable is enclosed in brackets to force the passing of the variable by value. See Passing Variables Byref and Byval.

Dim vntRet as Variant

' declare modular variant variable to store function results

Function TestCicode() As Integer

' declare local variables

Dim intRet As Integer

Dim strReply as String

Dim intMaxScale as Integer

' copy current tag value to variable

' uses the project variable tag named MAX_SCALE

intMaxScale = MAX_SCALE

' call Cicode function

' for example: TrnSetScale( AN, Pen, Percent, Scale)

intRet = CicodeCallOpen( "TrnSetScale", 53, -1, 100, (IntMaxScale)

)

' Note the syntax used:

' - brackets around the VBA function argument list.

' (This is only necessary when the VBA function is preceded

by an equals (=) sign .)

' - double quotes around the Cicode function name

' - no brackets around the Cicode function argument list

' - brackets around individual variable arguments

' test results

If intRet = 0 Then

'

' insert code for successful completion here

'

vntRet = CicodeCallReturn()

strReply = "CicodeCallOpen Function successfully called"

Else

'

' insert code for unsuccessful completion here

'

Select Case intRet

Case = 1

' assign return comment for this case

strReply = "CicodeCallOpen Function call error (unsuccessful)"

Case = 2

' assign return comment for this case

strReply = "Cicode Function not found"

Case = 3

' assign return comment for this case

strReply = "Wrong number of arguments "_

& "in Cicode CallOpen function call"

Case Else

' assign return comment for this case

strReply = "Unknown error"

End Select

End If

' display return comment for your information

MsgBox strReply

' assign return value for this function

TestCicode = intRet

End Function

In This Topic
TitleResults for “How to create a CRG?”Also Available in