Samples | PLC Set initialization value (ConsumeXml, C#) string setInitXml = @" MAIN.nInitValue 42 "; plcInstance.ConsumeXml(setInitXml); Retain variables Access to retain variables via the Automation Interface is read-only. VAR RETAIN is a TwinCAT PLC concept. The Automation Interface only allows the configuration to be read via ProduceXml . Retain variables are declared in the PLC code using the VAR RETAIN section and retain their values even after the PLC is restarted. PLC declaration PROGRAM MAIN VAR END_VAR VAR RETAIN nRem1 :
INT; END_VAR Sample XML (ProduceXml output from the PLC instance) 4 PlcTask Retains 0 11534336 MAIN.nRem1 16 INT 3096576 myProg.nRemain 16 INT 3137088 TE1000 235 Version: 1.7.0