'This script appends data to file.
Imports System        'Necessary classes imported to script
Imports System.IO
Imports System.Windows.Forms
Imports Microsoft.VisualBasic

Namespace WinTr

Public Class MainClass

           'Variables that will read and write
           'WinTr tags should be defined as Public.
          Public Tag_1 as Integer        
          Public Tag_2 as Integer
          Public Tag_3 as Single

          Public Sub Load        'Load procedure is defining.
                                       'Script starts working within this procedure.
                                       'WinTr tags should be accessed from this procedure.
                                       'When this procedure finished working,
                                       'WinTr tags can not be reached anymore from this script.


          '------- Script Start Line -------



               'C:\Example.txt file opening for appending.

          FileOpen(1,"C:\Example.txt", OpenMode.Append)
          Dim Str as String

       
          ' Tag values adding to string.

          Str = Tag_1 & ";" & Tag_2 & ";" & Tag_3    

          PrintLine(1, Str)              'String written into file.

          FileClose(1)                        'file closing.

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

          End Sub

End Class

End Namespace


Script for reading from file:

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


Namespace WinTr

Public Class MainClass


       'Variables that will read and write WinTr tags should be defined as Public.
          Public Tag_1 as Integer   
          Public Tag_2 as Integer
          Public Tag_3 as Single

          Public Sub Load

          '------- Script Start Line -------

          FileOpen(1,"C:\Example.txt", OpenMode.Input) 'File opening for reading.

          Dim Str_sp() as string

         Do While Not EOF(1)  'While loop to run until reaching end of the file.

           Str_Sp = Split(LineInput(1), ";") 'Line in the file transferring to variable.

                   Exit Do                   'Exiting from While loop.

          Loop

          FileClose(1)     'File closing.

          If Str_Sp.Length > 2 then

                    Tag_1 = Str_Sp(0)  'Data of string variable is transferring to Tags.

                    Tag_2 = Str_Sp(1)

                    Tag_3 = Str_Sp(2)

          End If

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

          End Sub

End Class

End Namespace


File Copying Script:


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

Namespace WinTr

Public Class MainClass

          Public Sub Load

          '------- Script Start Line -------


                               'If file exists
          If My.Computer.FileSystem.FileExists("C:\Example.txt") = False Then        
       

                               'File Copying
           FileCopy("C:\Example.txt", "C:\Example2.txt")                        

          End If

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

          End Sub

End Class

End Namespace




























Example Script: Script for appending data to file

                                                                                                                                                                       File System Script

                                                                                                                                                                               English                Turkish
Scada System        Scada Software        Free Scada            What is Scada
SCADA SOFTWARE