Negative Vorzeichen bei VOR

This commit is contained in:
2025-10-12 22:41:13 +02:00
parent 9864c1965f
commit ec4d7dc26e
45 changed files with 76 additions and 13 deletions

View File

@ -3,14 +3,41 @@ VAR
a UINT := 0;
b UINT := 0;
i UINT := 0;
sum DINT := 0;
flag BOOL := 0; // FALSE -> 0
x REAL := 1.5;
y LREAL := 2.5;
cnt INT := 0;
END_VAR
WHILE a < 5 DO
a := a + 1;
// Einfacher If-Test
IF a = 0 THEN
a := 1;
END_IF;
// While-Schleife mit arithmetischen Ausdrücken
WHILE cnt < 3 DO
cnt := cnt + 1;
b := b + cnt * 2;
END_WHILE;
FOR i := 1 TO 10 DO
b := b + i;
// For-Schleife mit BY und verschachteltem IF
FOR i := 1 TO 10 BY 2 DO
sum := sum + i;
IF i <> 5 THEN
flag := 1; // TRUE -> 1
ELSE
flag := 0; // FALSE -> 0
END_IF;
END_FOR;
// Abwärts-Schleife (negativer BY-Wert)
FOR i := 5 TO 1 BY -1 DO
sum := sum + i;
b := b + (i * (cnt + 1));
END_FOR;
// Rechnen mit Gleitkommazahlen
x := x + y / 2.0;
END_PROGRAM