WinTr allows scripting. Scripts can be used in screen and object functions. Thus they can be triggerred when specific event occurred. For example, scripts can be run when screen refreshed or user pressed and released mouse button when cursur placed on some control(button,radio button, etc...)

Internal ve External Tags can be read and write as they are variable.

Scripts can be written in Visual Basic or C# languages.

In WinTr, any operation that can be done with this languages is able to be performed via scripts

Script Writer is reached by clicking Script Writer in the menu which opens by clicking on the Editors button.
Accessing Script Writer
Script Writer opens with automatically generated codes. These codes contains imported classes and needed class and procedure definitions.
To reach WinTr tags from the script,

In VB, variable definitions should be placed between Public Class MainClass  and Public Sub Load lines and they should be defined in

Public [Tag_name] as [Type]

structure.


In C#:

Variable definitions should be placed between Class MainClass and Public Void Load lines and they should be defined in

Public [Type]  [Tag_name]

structure.

(please refer following images)

Following simple script assigns random numbers to WinTr tags in both VB and C# languages.

Compiling and Running the Scripts:

Script is tested against the errors and compiled by clicking Test button on ToolStrip.
Script should be compiled in order to save.
Test and run button runs the script after compiling it. WinTr tags can be written in this way.

Compiling and running the script
Selecting scripting language
Creating and Saving the Script:

Creating and saving script operations made by toolstrip buttons.
New button creates new script file.

Open button displays file open dialog box for opening existing script file.
Opening existing script
Save button displays file saving dialog box for saving the script.

Save as button saves the script in different name.

Save buttons are disabled while writing the script. To enable them script should be compiled by Test button.

After the script executed in runtime, it can not be overwritten in the same session. It can be saved by save as method or Wintr should be restarted.
Running Scripts in the Runtime:

In runtime, scripts are called from screen and object functions.

Screen's  Screen Loading, Screen Refresh and Screen Closing functions can call scripts.

Scripts can be added screen functions by selecting Screen Loading, Screen Refresh and Screen Closing events for the function on screen properties menu which appears when right clicking on the screen.

Running Scripts in Runtime
Assigning scripts to object functions
Scripts can be added object functions by selecting an event for the function on properties menu which appears when right clicking on the object.
To add script to function, select script from Action Script section then click add button. Script will be added to function list of related event.

Adding scripts to Function List
Script codes may have single quote (') started explanations.
Rest of the single quote will be ignored by the compiler.
Using Procedure and Functions in Script

Procedures and functions can be called from Public Sub Load procedure.

In VB, difference between function and procedure is functions can return a value.

In C# if it is wanted to procedure return a value, type of the return value should be declared before the name of the procedure while defining it.

They can read and write WinTr tags when they called from the Load procedure, .  
Parameters can be used in procedure and functions.

Following scripts are the sample scripts for the procedure and function usage in the VB and C# languages. 
Using Form Interface and Object Events in Scripts:

Graphical user interface can be used in scripts which contains controls(button, textbox, checkbox, etc....) and allows user interaction.
How Work Scripts within WinTr?

When a script triggerred in Runtime, its starts running from the 'Load' procedure. SCADA tags set when it is reached last line of this procedure.

After Load procedure is done, even if script continues to running it can not reach to WinTr tags.

Therefore the script should be designed as the commands that reads and writes WinTr tags called between the Script Start Line and Script End Line lines.
Accessing WinTr Tags from the script:

Scripting language is determined from the combobox on the toolstrip as Visual Basic or C#. (The examples in this pages is written in Visual Basic)
To create a graphical interface, form type object should be created and it must be displayed with showdialog method in Public Sub Load procedure.

Control objects(button,textbox...) added to the form by

[form_name].controls.add([control_name])

command.

Event handlers should be added to script as described at the bottom.
Adding scripts to Function List
Accessing Script Writer
Script Writer - VB Compiler
Selecting scripting language
Defining SCADA Tags inside the script and assigning random numbers in VB
Form interface of script
Compiling and running the script
Creating and saving the script
Opening existing script
Running Scripts in Runtime
Assigning scripts to object functions

                                                                                                                                                                       Script Writer
Defining SCADA Tags inside the script and assigning random numbers in VB.
VB Code:

Imports System
Imports System.IO
Imports System.Windows.Forms
Imports Microsoft.VisualBasic

Namespace WinTr
Public Class MainClass

Public Tag_1 as Uint16
Public Tag_2 as Uint16
Public Tag_3 as Uint16

Public Sub Load
'------- Script Start Line -----

procedure(Tag_2,Tag_3) 'calling a procedure from load procedure
Tag_1=func(Tag_2,Tag_3) 'calling func function from load procedure.

'------- Script End Line -------
End Sub

Sub procedure (parametre1 as Uint16 , parametre2 as Uint16) 'definition of procedure named procedure
Tag_1=parametre1+parametre2
end sub

Function func(parametre1 as Uint16 , parametre2 as Uint16) 'definition of func named function
func=(parametre1+parametre2)*2
end function

End Class
End Namespace
Imports System
Imports System.IO
Imports System.Windows.Forms
Imports Microsoft.VisualBasic

Namespace WinTr
Public Class MainClass
       Public Tag_1 as Uint16
       'Because of it will be used with it's events, Button is defining with withevents keyword.
       Private Withevents btn as New Button
       Public Sub Load
       '------- Script Start Line -------

       Dim frm as new form 'displayed form is defined
       frm.controls.add(btn) 'button is added to form
       frm.showdialog        'form is showing. If it is not displayed by
                               'showdialog method, WinTr tags can not be accessed.
       '------- Script End Line -------
       End Sub
       Sub btnhandler (sender as object,e as system.eventargs) Handles btn.click 'button's 'click' handler
       Tag_1=1
       End sub

End Class
End Namespace
Form interface of script
Creating and saving the script
If an error detected after compiling the script, errors will be listed bottom of the Script Writer. When double clicked on the error, related line will be highlighted.
Derleme sonucunda hataların tesbit edilmesi
Script Writer - C# compiler
Defining SCADA Tags inside the script and assigning random numbers in C#
Defining SCADA Tags inside the script and assigning random numbers in C#
C# Code:

using System;
using System.IO;
using System.Windows.Forms;
using Microsoft.CSharp;

namespace WinTr
{
class MainClass
{

public UInt16 Tag_1;
public UInt16 Tag_2;
public UInt16 Tag_3;

       public void Load()
       {
       //------- Script Start Line -----

       Tag_1=procedure(Tag_2,Tag_3); 'calling procedure from load procedure

       //------- Script End Line -------
       }

'defining a procedure with UInt16 type return value
public UInt16 procedure(UInt16 parametre1, UInt16 parametre2)
{

return (UInt16)((parametre1+parametre2)*2);

}

}
}

Projede kullanılan Scriptlerin Cross reference olarak gösterilmesi
When a script opened in Script Writer the places which uses this script will be listed at right side as Cross Reference.
Listing the places that use script as Cross Reference

                                                                                                                                                                               English                Turkish
Zoom In - Zoom Out button increases and decreases of the characters.

Search button highlights a specific tag in the list.

Command buttons switches a line to comment or non-comment.

In Line - Out Line buttons move the line to right and left.
Script ToolBar
Script Toolbar
Script Writer - VB Compiler
Script Writer - C# compiler
Derleme sonucunda hataların tesbit edilmesi
Scada System        Scada Software        Free Scada            What is Scada
SCADA SOFTWARE