>>Message imported from previous forum - Category:Scripts and Tips<<
User: ngh, originally posted: 2019-10-16 04:35:34 Id:561
Hi guys,
Does anybody know how to bring up the edit note interface/method in a script?
I'm after something like:
Set obj = Server.ThisObject
obj.editNote ' This line doesnt work obviously
The best I can do so far is display an object menu with only the edit notes option. But that requires an extra click and annoys me too much.
Thanks!
>>Responses imported from previous forum
Reply From User: geoffpatton, posted: 2019-10-16 17:26:38
Sounds similar to what I once did. On the mimic I have a Text box that shows the notes and then a button that lets the user edit the notes.
Function MaintEdit
Dim MaintNotes, objStationCmd, iMessage
Dim frmEditBox, frmOKButton, frmCancelButton
MaintNotes = Server.GetOPCValue(".Info.NoteTextLong")
Set objStationCmd = Server.FindObject(Server.GetOPCValue(".Info.Fullname"))
If objStationCmd.CheckAccess("CTL") = True Then
'DisplayObjectMenu ".Info", "NoView&NoAlarmView&NoHelpView&NoDefaultView&NoEvents&NoAlarms&NoDisplay&NoQueries&NoTrends&NoMethods&NoErrors&NoRefs&NoProperties&NoEdit&NoLinks&NoNavSync&NoNavSyncTempl&NoUserMethods&NoLocateOPCNavigator"
Form.Init "Display Maint. Log"
Form.AddGroupBox 0,0,110,30,""
Form.AddStaticText 2,2, "Edit Information"
Set frmEditBox = Form.AddEditBox(2,4,100,20)
frmEditBox.MaxLength = 30000
frmEditBox.Value = MaintNotes
frmEditBox.VScroll = True
frmEditBox.SelectText = 0
Set frmOKButton = Form.AddPushButton(2,27,"OK")
frmOKButton.Default = True
Set frmCancelButton = Form.AddPushButton(17,27,"Cancel")
Form.Show
If Form.Selection = "OK" Then
Server.SetOPCValue ".Info.NoteTextLong", frmEditBox.Value
End If
Else
Form.Init "Display Maint. Log"
Form.AddGroupBox 0,0,110,30,"This is not an editable form. To edit the Log, logon as a user with editing rigths."
Form.AddStaticText 2,2, "View Information"
Set frmEditBox = Form.AddEditBox(2,4,100,20)
frmEditBox.MaxLength = 30000
frmEditBox.Value = MaintNotes
frmEditBox.VScroll = True
frmEditBox.ReadOnly = True
frmEditBox.SelectText = 0
Set frmOKButton = Form.AddPushButton(2,27,"OK")
frmOKButton.Default = True
Form.Show
End If
End Function
Reply From User: ngh, posted: 2019-10-16 21:45:24
Thanks geoff! I was hoping to avoid implementing my own edit notes form but I guess that might be my only option.
Reply From User: geoffpatton, posted: 2019-10-18 18:30:05
Yeah, I would have loved something simpler. That was the only thing I could get to work as a one click option.
Reply From User: tfranklin, posted: 2019-10-23 15:55:38
[at]geoffpatton said:
Yeah, I would have loved something simpler. That was the only thing I could get to work as a one click option.
I feel the same way about Control for currentvalue on a point. Using the native Control dialogue for a analog or digital point would be much preferred due to it handling states, limits, and errors already. To control from a custom script pick action menu you'd have to re-write the error handling process with a form rather than something that's just like obj.interface.control and it calls the native control for that object. Obviously we can set the value in script with a single click, but being able to call the native dialogue to allow users to enter a value would be ideal.
Reply From User: geoffpatton, posted: 2019-10-24 13:59:28
[at]tfranklin said:
To control from a custom script pick action menu you'd have to re-write the error handling process with a form
I have done this error checking in script, and it was much more complex. Actually I think the first time I did anything more complex than check for control permissions it was necessary no matter what. I had to write High byte and Low byte for two different settings so I would have had to check the value was valid for the byte and then write the words.
I recycled that code on future forms.
>>Responses imported from previous forum
Reply From User: geoffpatton, posted: 2019-10-16 17:26:38
Sounds similar to what I once did. On the mimic I have a Text box that shows the notes and then a button that lets the user edit the notes.
Function MaintEdit
Dim MaintNotes, objStationCmd, iMessage
Dim frmEditBox, frmOKButton, frmCancelButton
MaintNotes = Server.GetOPCValue(".Info.NoteTextLong")
Set objStationCmd = Server.FindObject(Server.GetOPCValue(".Info.Fullname"))
If objStationCmd.CheckAccess("CTL") = True Then
'DisplayObjectMenu ".Info", "NoView&NoAlarmView&NoHelpView&NoDefaultView&NoEvents&NoAlarms&NoDisplay&NoQueries&NoTrends&NoMethods&NoErrors&NoRefs&NoProperties&NoEdit&NoLinks&NoNavSync&NoNavSyncTempl&NoUserMethods&NoLocateOPCNavigator"
Form.Init "Display Maint. Log"
Form.AddGroupBox 0,0,110,30,""
Form.AddStaticText 2,2, "Edit Information"
Set frmEditBox = Form.AddEditBox(2,4,100,20)
frmEditBox.MaxLength = 30000
frmEditBox.Value = MaintNotes
frmEditBox.VScroll = True
frmEditBox.SelectText = 0
Set frmOKButton = Form.AddPushButton(2,27,"OK")
frmOKButton.Default = True
Set frmCancelButton = Form.AddPushButton(17,27,"Cancel")
Form.Show
If Form.Selection = "OK" Then
Server.SetOPCValue ".Info.NoteTextLong", frmEditBox.Value
End If
Else
Form.Init "Display Maint. Log"
Form.AddGroupBox 0,0,110,30,"This is not an editable form. To edit the Log, logon as a user with editing rigths."
Form.AddStaticText 2,2, "View Information"
Set frmEditBox = Form.AddEditBox(2,4,100,20)
frmEditBox.MaxLength = 30000
frmEditBox.Value = MaintNotes
frmEditBox.VScroll = True
frmEditBox.ReadOnly = True
frmEditBox.SelectText = 0
Set frmOKButton = Form.AddPushButton(2,27,"OK")
frmOKButton.Default = True
Form.Show
End If
End Function
Reply From User: ngh, posted: 2019-10-16 21:45:24
Thanks geoff! I was hoping to avoid implementing my own edit notes form but I guess that might be my only option.
Reply From User: geoffpatton, posted: 2019-10-18 18:30:05
Yeah, I would have loved something simpler. That was the only thing I could get to work as a one click option.
Reply From User: tfranklin, posted: 2019-10-23 15:55:38
[at]geoffpatton said:
Yeah, I would have loved something simpler. That was the only thing I could get to work as a one click option.
I feel the same way about Control for currentvalue on a point. Using the native Control dialogue for a analog or digital point would be much preferred due to it handling states, limits, and errors already. To control from a custom script pick action menu you'd have to re-write the error handling process with a form rather than something that's just like obj.interface.control and it calls the native control for that object. Obviously we can set the value in script with a single click, but being able to call the native dialogue to allow users to enter a value would be ideal.
Reply From User: geoffpatton, posted: 2019-10-24 13:59:28
[at]tfranklin said:
To control from a custom script pick action menu you'd have to re-write the error handling process with a form
I have done this error checking in script, and it was much more complex. Actually I think the first time I did anything more complex than check for control permissions it was necessary no matter what. I had to write High byte and Low byte for two different settings so I would have had to check the value was valid for the byte and then write the words.
I recycled that code on future forms.
User | Count |
---|---|
188 | |
56 | |
17 | |
17 | |
16 | |
10 |
Discuss challenges in energy and automation with 30,000+ experts and peers.
Find answers in 10,000+ support articles to help solve your product and business challenges.
Find peer based solutions to your questions. Provide answers for fellow community members!