Example Script : Reading and Writing WinTr Tags from the Script
'This script writes to WinTr Tags
Imports System 'Importing needed classes.
Imports System.IO
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Namespace WinTr
Public Class MainClass
Public Tag_1 as Int16 'Variables that will read and write WinTr tags should be defined as Public.
Public Tag_2 as Integer 'integer 32
Public Tag_3 as Int32
Public Tag_4 as Boolean
Public Tag_5 as Single 'Floatpoint
Public Tag_6 as String
Public Tag_7 as Datetime
Public Now as Datetime
Public Sub Load 'Load procedure is defining.
'Script starts working within this procedure.
'WinTr tags should be accessed from this procedure.
'After this procedure finished working
'WinTr tags can not be reached anymore from whole script.
'------- Script Start Line -------
Tag_1 = 123 'Values assigning to tags.
Tag_2 = 123000
Tag_3 = 123000
Tag_4 = True
Tag_5 = 123.12
Tag_6 = "Fultek"
Tag_7 = Now
'------- Script End Line -------
End Sub
End Class
End Namespace
C# Code:
//Importing needed classes.
using System;
using System.IO;
using System.Windows.Forms;
using Microsoft.VisualBasic;
namespace WinTr
{
public class MainClass
{
//Variables that will read and write WinTr tags should be defined as Public.
public UInt16 Tag_1;
//integer 32
public UInt32 Tag_2;
public UInt32 Tag_3;
public bool Tag_4;
//Floatpoint
public float Tag_5;
public string Tag_6;
public DateTime Tag_7;
public DateTime Now;
public void Load() //Load procedure is being defined. Script starts working within this procedure.
//WinTr tags should be accessed from this procedure. After this procedure finished working
//WinTr tags can not be reached anymore from whole script.
{
//------- Script Start Line -------
//Taglara değerler atanıyor.
Tag_1 = 123;
Tag_2 = 123000; 'Values assigning to tags.
Tag_3 = 123000;
Tag_4 = true;
Tag_5 = 123.12F;
Tag_6 = "Fultek";
Tag_7 = Now;
//------- Script End Line -------
}
}
}
All tags should be defined as Public. Script fetches tag values at the beginning and writes values at the end of the Load procedure.