Subscribing is a smart move!
You can subscribe to this forum after you log in or create your free account.
Geo SCADA Knowledge Base
Access vast amounts of technical know-how and pro tips from our community of Geo SCADA experts.
Originally published on Geo SCADA Knowledge Base by sbeadle1 | June 09, 2021 11:56 PM
'constantsDim SYSTEM_NAME As StringDim USER_NAME As StringDim SYSTEM_PASSWORD As StringSub Logic()'declare these constants!!SYSTEM_NAME = ""USER_NAME = ""SYSTEM_PASSWORD = ""' Connect to ServerDim objServer As New ScxV6ServerobjServer.Connect SYSTEM_NAME, USER_NAME, SYSTEM_PASSWORD' Create ST Program object and rename itDim prog As ScxV6ObjectSet prog = objServer.CreateObject("CLogicSTProgram", "$Root")prog.Rename "Example Logic"'Attach to ViewXDim v As ViewX.ApplicationSet v = New ViewX.Applicationv.Visible = True'Open ST Program documentDim STProg As ViewXLogic.LogicSTProgramSet STProg = ViewX.Documents("CLogicSTProgram").OpenFromServer(False, SYSTEM_NAME, "Example Logic")' write text to programDim text As Stringtext = "PROGRAM ExampleLogic" + vbCrLftext = text + "code here;" + vbCrLftext = text + "END_PROGRAM"STProg.SetProgramAndSave (text)' Close windowSTProg.CloseobjServer.DisconnectSet objServer = NothingEnd Sub
Create your free account or log in to subscribe to the forum - and gain access to more than 10,000+ support articles along with insights from experts and peers.