0

I'm trying to get my head into the Codesys world and since I'm not a Menu-click type I'm wondering if there is a way to stick to the keyboard and for instance add a PersistentVarsList and Global Vars List via Structured Text in the Editor.

riQQ
  • 9,878
  • 7
  • 49
  • 66
aerioeus
  • 1,348
  • 1
  • 16
  • 41

1 Answers1

0

If by add PersistentVarsList/Global Vars list you mean to crate a new list inside the project from Structured Text code, then no. If you just have some variable list (non constant!) inside your project that you want to initialize in runtime (perhaps their values need to be calculated first), then you can have some code that only executes at the begining of the runtime:

PROGRAM POU_1
VAR
    init: BOOL := FALSE;
END_VAR
IF (NOT init) THEN
    myGVL.someVar := CALLCULATE_VAR();
    IF (myPersist.positiveVar < 0) THEN
        myPersist.positiveVar := -myPersist.positiveVar;
    END_IF
    // other initializations
    init := TRUE;
END_IF
Guiorgy
  • 1,405
  • 9
  • 26