DeltaV Operate Error trapping (scripting)

Hi All, 

(newbie in scripting) I am trying to trap an error where if the parameter is not available/configured, skip the code.

 i tried "On Error" before and after the line but still getting "err number of -1577058273" no such parameter in module. I also tried "[NOT_CONFIGURED_OK]". 

here's my code:


Dim AlarmStatus As String

On Error GoTo ErrHandler
AlarmStatus = frsreadvalue("DVSYS.@MOD@/HI_HI_ALARM.F_ENAB")

On Error GoTo ErrHandler
If AlarmStatus = True Then

Dim AlarmPath As String
AlarmPath = frsreadvalue("DVSYS.@MOD@/DESC.A_MODULETAG")

frsRunTask "AlarmHelp", AlarmPath + "/HI_HI_ALARM"

End If

Exit Sub

ErrHandler:

MsgBox "No Alarm configured hence no Alarm Help available"

End If

10 Replies

  • To save a lot of explanation I suggest you search for frsReadValue in BOL and read the description.
    The error number is always available as optional argument lngErrNumber. frsReadValue generates an error dialog if argument blnShowErrorDialog is True, which it is by default.
  • Try the below changes in Red to trap the existence of the alarm.

    Dim AlarmStatus As String
    Dim lError As Long

    On Error GoTo ErrHandler
    AlarmStatus = frsreadvalue("DVSYS.@MOD@/HI_HI_ALARM.F_ENAB", lError, , False)

    If lError = 0 Then
      If AlarmStatus = True Then

        Dim AlarmPath As String
        AlarmPath = frsreadvalue("DVSYS.@MOD@/DESC.A_MODULETAG")

        frsRunTask "AlarmHelp", AlarmPath + "/HI_HI_ALARM"
      End If
    Else
      MsgBox "No Alarm configured hence no Alarm Help available"
    End If

    Exit Sub

    ErrHandler:
      frsHandleError

  • In reply to Matt Stoner:

    Hi Matt, thanks for the code.

    cheers,
    Gelo
  • In reply to GeloCortez:

    how do I select the answer?
  • In reply to GeloCortez:

    Hi Gelo~

    Thanks for asking. Currently, the default settings in the community are set to "discussion". We will be testing this with users at the Emerson Exchange in October :) However, in the future, you will want to choose QUESTION in the default menu when creating post. Then, choose Mark as Answer in the prompts under each response when you find one or more than has provided you with a solution.

    Best Regards,

    Rachelle McWright: Business Development Manager, Dynamic Simulation: U.S. Gulf Coast

  • In reply to Rachelle McWright:

    Hi Ms. Rachelle,

    i'll keep this in mind. :D Thanks
  • In reply to Matt Stoner:

    Hi Matt,
    How to make relation between the parameter @mod@ with the informations of deltav explorer such as a control module or a sis module?

    I have a faceplate for sis module, and it is used to make relation with deltav explorer the parameter @modfb@ but i want to write in control module in the same time with @mod@, however @mod@ is not recognized.

    This is my code:

    Private Sub GrpBypassA1One1_Click()

    On Error GoTo ErrorHandler

    frsSecureToggle GrpBypassA1One1, "DVSYS.@modfb@/LSAI1_HH/BYPASS1.F_CV", frsvariables.gs_sw_text16.CurrentValue, frsvariables.gs_sw_text17.CurrentValue, "DVSYS.@modfb@/LSAI1_HH/DESC1.A_CV"

    frswritevalue 1, ("DVSYS.@mod@/INTER.F_CV")

    Exit Sub
    ErrorHandler:
    frsHandleError
    End Sub
  • In reply to MILONGO Rodolph:

    Hi Milongo,
    You have replied to another query with a question.

    It will be better to start a new discussion.

    Now coming back to your question

    @mod@ is available on faceplates only. As you have @modfb@, I assume you are using a function block faceplate.
    You need to strip the function block name from @modfb@ to get the module name and then use frsWrite.

    Try the code below
    '-------------------------------
    Dim sPath as string
    Dim sModule as string
    Const sFB as string = "/PID1" 'Replace with correct function block name and include initial '/'

    sPath = "DVSYS.@modfb@/LSAI1_HH/BYPASS1.F_CV"

    frsSecureToggle GrpBypassA1One1, sPath, frsvariables.gs_sw_text16.CurrentValue, frsvariables.gs_sw_text17.CurrentValue, "DVSYS.@modfb@/LSAI1_HH/DESC1.A_CV"

    sModule = replace(sPath, sFB & "/LSAI1_HH/BYPASS1.F_CV", "") 'This will strip the path and leave you with DVDSYS.MODULENAME

    frswritevalue 1, (sModule & "/INTER.F_CV")
    '-------------------------------

    Thanks
    Amod
  • In reply to Amod Gokhale:

    Hi Amod,

    I try your code but I have an error such as tag is undefined. It has joined the parameters like DVSYS.@modfb@/LSAI1_HH/BYPASS1.F_CV/INTER.F_CV

    I have added the MSGBOX(sModule) and it displays DVSYS.@modfb@/LSAI1_HH/BYPASS1.

    Thanks
  • In reply to MILONGO Rodolph:

    Add the following logic before your frswritevalue logic:

    frsDisassemblePath ps_nmb.CurrentValue, Server, , ModuleTag, , , , , , , , strZone

    Then you will need to change the frswritevalue to use "DVSYS." & ModuleTag & "/INTER.F_CV"

    The variable ps_nmb used above should exist in your display and will be defaulted to what @modfb@ will be. I think you can use @modfb@ instead of the variable as well if you find the variable doesn't exist for some reason.