Applies To:
  • CitectSCADA
  • CitectHMI

How to read data from a binary file into citect variable tags using CiVBA

See example below


Sub ReadFile()

Dim Single2 As Single
    Open "C:\per2sec.dat" For Binary As #1
    'Loc1 is a LONG variable tag in Citect
    'This sets the start location in the file to read from in bytes
    'eg To read the 7th REAL in the file you would first set this to 25
    Seek #1,Loc1
    'Get wants to put its result into a VB variable hence
    'I use Single2 here rather than use Single1 directly
    Get #1, , Single2
    Close #1
    Single1 = Single2 'Single1 is a REAL variable tag in Citect
End Sub