OkToWrite

(VTScada-Layer function. Must be called with a leading backslash.)

Description: Returns true if a user is permitted to control a particular tag on a particular workstation.
Returns: Boolean
Usage: Script or steady state.
Function Groups:  
Related to: CanControl (Control Lock Manager) | CanControl (Control Token Manager) | Set
Format: \OkToWrite([SecurityPrivilege, Feedback, EnableOutput, TagObj, DisableControl])
Parameters:  
SecurityPrivilege
Optional integer. The tag's custom security privilege, if it has one. Most often set to \Root.SecurityBit. Whether or not this is provided, the user must also have the Control Outputs privilege.
Feedback
Optional Boolean. TRUE to allow a feedback dialog to appear if permission cannot be granted. FASLE to suppress the dialog. Defaults to FALSE.
EnableOutput
Optional Boolean. TRUE if the I/O tag has its output capability is enabled. Most often set to \Root.EnableOutput. Defaults to TRUE.
TagObj
Optional tag object. The I/O tag being controlled. Defaults to the calling tag
DisableControl
Optional. TRUE to disable control. Most often set by the widget according to its own internal logic or parameters. Defaults to FALSE.
Comments:

All widgets that are used for writing a value to a PLC or storing a value in a memory tag should call OkToWrite prior to calling the tag's Set() module. It can also be called in steady state to determine whether to visually enable or disable the widget's graphics.

Permission is granted based on several factors including user security, tag configuration, read-only-workstation configuration, realm filtering, control locks and control tokens.

If OkToWrite is to be used as a Called module (such as, within a widget) FeedBack must be False, otherwise the Popup dialog would show by switching users or pages, which is not the intent.

Example 1:

  If WinButton();
  [
    IfThen(\OkToWrite(\Root.SecurityBit, TRUE, \Root.EnableOutput, \Root, DisableControl),
      \Root.Set(Value);
    );
  ]

Example 2:

  EnableButton = \OkToWrite(\Root.SecurityBit, FALSE, \Root.EnableOutput, \Root, DisableControl)
  If WinButton(232, 148, 412, 100,
               0                    { normal appearance }, 
               Concat("Press Me ", ButtonPresses) { label },
               EnableButton         { focus id enables button },
               0                    { default system font },
               ToggleVal            { monitor state});
  [
  [
    \Root.Set(Value);
  ]