Skip to content

Instantly share code, notes, and snippets.

@ejs94
Created July 28, 2020 03:17
Show Gist options
  • Save ejs94/74d95c54334683f7ed8c07685ca99c07 to your computer and use it in GitHub Desktop.
Save ejs94/74d95c54334683f7ed8c07685ca99c07 to your computer and use it in GitHub Desktop.
Returns the number of elements in an array in structured text (iec 61131-3)
(* Structured Text (IEC 61131-3) *)
SIZEOF(Array); // Return size of entire Array in bytes
SIZEOF(Array[0]); // Return size of one element
SIZEOF(Array)/SIZEOF(Array[0]); // Return number of elements
// Example use
for( i = 0 ; i < SIZEOF(Array)/SIZEOF(Array[0]) ; i++){
// loop
}
(*
Source: https://www.youtube.com/watch?v=fakMnyWtFSw
Coding Best Practices - This is Automation
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment