Loose variables turn into a mess quickly. Group the ones that belong together into a named shape, a STRUCT, and your code starts to read like the machine it controls.
A bottling line has a recipe with a fill volume, a cap torque and a label flag. You can hold that as three loose variables or as one tidy ST_Recipe. Edit the fields and the Structured Text updates to match.
π‘ Now Line1.recipe is one variable you can pass around, copy, or store as an array of recipes, where before you had three to juggle. Add a field to the type and every recipe gets it for free.
ENUM: readable states
Instead of "mode = 2", say what you mean. Click a mode:
UNION: one memory, two views
TYPE U_Word : UNION asWord : WORD; // all 16 bits asBytes : ARRAY[0..1] OF BYTE; END_UNION END_TYPE
Both members share the same bytes. Write asWord and read asBytes[0], which is handy for decoding a fieldbus register without bit-shifting by hand.
You write to myWord.asWord. What happens to myWord.asBytes?