DeltaV 14.3.1 Operate VBA Scripting an ASCII Converter on Data Change

Goal: take an integer from 0-255 and dynamically convert it to an ASCII character at run-time.

Current (non-working) solution:

  1. Datalink and 2 local variables created (dtlASCII, intASCII, strASCII)
  2. Datalink connected to strASCII variable
  3. intASCII variable animated current value (w/ format) pointed toward CM w/ ACSII 0-255 value
    1. Succesfully reading the intASCII value when using test Datalink to observe
  4. R-click edit script and have the following script:
    1. Private Sub intASCII_OnChange()
      On Error GoTo ErrorHandler
      With frsvariables
          Dim strLocASCII As String
          Dim intLocASCII As Long
          intLocASCII = intASCII.CurrentValue
          strLocASCII = Chr(intLocASCII)
          frsWriteValue strLocASCII, strASCII.CurrentValue, , , False     'This is where I think the problem is, not sure how to write back up to variables
      End With
      Exit Sub
      ErrorHandler:
          frsHandleError
      End Sub
    2. Failure at this script, the Chr() function works fine to convert but the value doesn't get back up to the graphic level variable strASCII

Any help is appreciated! Or guidance to instruction in using the Operate VBA functions would be great.

Have a good day,

Ben Merryman

  • I was overcomplicating things.  frsWriteValue is for DeltaV datapoints, not graphics.  The following script accomplishes what I was looking for:

    Private Sub intBchNm0_OnChange()

       On Error Resume Next

       strBchNm0.CurrentValue = Chr(intBchNm0.CurrentValue)

    End Sub

    Ben Merryman