Glossary Updates12 new terms added to the glossaries · October 2, 2026, 22:44 CEST
AI TechDocKnowledge

Glossary · PLC and control programming

Local variable

Also known as: VAR, Internal variable, Temporary variable

German: Lokale Variable

In IEC 61131-3 programming, a local variable is a variable declared inside a program organization unit, for example with VAR or VAR_TEMP, that is visible only within that unit.

  • PLC programming
  • Standards

In one sentence

A local variable is declared inside one PLC program unit and visible only there, which keeps data encapsulated.

Example

Inside FB_Motor, the local variable tStartDelay holds a timer instance that no other part of the program can access.

How it applies

  • Engineering: Local variables encapsulate data. In a function block, static local variables (VAR) keep their value between calls; temporary variables (VAR_TEMP) exist only during one execution and must be initialized before use. Using a temporary variable before assigning it is a classic error.
  • Reuse: Blocks that use only local data and their interface parameters can be reused and tested in isolation. Hidden dependencies on global data defeat this.
  • Maintenance: Local names can repeat across blocks without conflict, which keeps naming simple.
  • Documentation: Local variables are normally internal and not part of the external documentation. Exceptions are values that service staff monitor online for diagnosis; list those in the block's reference documentation.

Local variable vs. global variable

A local variable is visible only in its own unit. A Global variable is visible program-wide. Prefer local variables and pass data through interfaces.

By knowledge.aitechdoc.world · Published September 26, 2026 · Last reviewed

Source: IEC 61131-3, Programmable controllers — Part 3: Programming languages

Definitions follow the cited standards and specifications. Where a source is a copyrighted publication, such as an ISO, IEC or EN standard, the definition is a close paraphrase, not a verbatim quotation, so as not to infringe copyright. We recommend reading the original publication. The sections “How it applies” are editorial commentary by AI TechDoc Knowledge and are not part of any standard.

Seen a mistake? Send us a note!