Tony763
Hello, I would like to use data and time for some automatons.  I firstly want to test in editor simulation, so I exactly see, what output will be given.

I started and ended with date conversion

I declared NOWDATE  (DATE) and  NOW2 (ULINT ) with value of current epoch time then pass it to ULINT_TO_DATE. 
NOW2          := ULINT;
NOWDATE       := DATE


NOW2 := 1615846772;
ULINT_TO_DATE(
     IN := NOW2,
     OUT => NOWDATE)


It ended with:
Start build in /home/user/data/F/build
Generating SoftPLC IEC-61131 ST/IL/SFC code...
Compiling IEC Program into C code...
"/OpenPLC_Editor/matiec/iec2c"  -f -l -p -I "/OpenPLC_Editor/matiec/lib" -T "/home/user/data/F/build" "/home/user/data/F/build/plc.st"
exited with status 1 (pid 1047)
/home/user/data/F/build/plc.st:102-3..103-10: error: invalid variable before ':=' in ST assignment statement.
In section: PROGRAM program0
0102:   ULINT_TO_DATE(
0103:        IN := NOW2,
/home/user/data/F/build/plc.st:103-17..103-18: error: ';' missing at the end of statement in ST statement.
In section: PROGRAM program0
0103:        IN := NOW2,
/home/user/data/F/build/plc.st:103-18..111-23: error: invalid variable before ':=' in ST assignment statement.
In section: PROGRAM program0
0103:        IN := NOW2,
0104:        OUT => NOWDATE)
In section: END_PROGRAM
0105: END_PROGRAM
0106: 
0107: 
In section: CONFIGURATION Config0
0108: CONFIGURATION Config0
0109: 
0110:   RESOURCE Res0 ON PLC
0111:     TASK task0(INTERVAL := T#20ms,PRIORITY := 0);
/home/user/data/F/build/plc.st:111-33..111-34: error: ';' missing at the end of statement in ST statement.
In section: CONFIGURATION Config0
0111:     TASK task0(INTERVAL := T#20ms,PRIORITY := 0);
/home/user/data/F/build/plc.st:111-34..111-42: error: invalid variable before ':=' in ST assignment statement.
In section: CONFIGURATION Config0
0111:     TASK task0(INTERVAL := T#20ms,PRIORITY := 0);
/home/user/data/F/build/plc.st:111-47..111-48: error: ';' missing at the end of statement in ST statement.
In section: CONFIGURATION Config0
0111:     TASK task0(INTERVAL := T#20ms,PRIORITY := 0);
/home/user/data/F/build/plc.st:111-48..111-48: error: invalid statement in ST statement.
In section: CONFIGURATION Config0
0111:     TASK task0(INTERVAL := T#20ms,PRIORITY := 0);
/home/user/data/F/build/plc.st:112-6..112-43: error: invalid statement in ST statement.
In section: CONFIGURATION Config0
0112:     PROGRAM instance0 WITH task0 : program0;
Parsing failed because of too many consecutive syntax errors. Bailing out!
Error : IEC to C compiler returned 1


Any hint?
Reply 0 0
thiagoralves
You're missing semicolons ';' at the end of your statements
Reply 0 0
Tony763
Hello, I added it, but error is still there:

NOW2 := 1615846772;
ULINT_TO_DATE(
     IN := NOW2,
     OUT => NOWDATE);


exited with status 1 (pid 3145)
/home/user/data/Gate_Controller/build/plc.st:324-3..325-10: error: invalid variable before ':=' in ST assignment statement.
In section: PROGRAM Main
0324:   ULINT_TO_DATE(
0325:        IN := NOW2,
/home/user/data/Gate_Controller/build/plc.st:325-17..325-18: error: ';' missing at the end of statement in ST statement.
In section: PROGRAM Main
0325:        IN := NOW2,
/home/user/data/Gate_Controller/build/plc.st:325-18..326-22: error: invalid statement in ST statement.
In section: PROGRAM Main
0325:        IN := NOW2,
0326:        OUT => NOWDATE);
3 error(s) found. Bailing out!
Reply 0 0
thiagoralves
Try doing it this way:
NOWDATE := ULINT_TO_DATE(NOW2);
Reply 1 0
Tony763
Thank You,
this works.

Is it possible to change this also in Library? If I add this function from it, its imported in format mentioned above.
Reply 0 0
Reply