KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to detect if an array has been created
PRODUCT: 4D | VERSION: 2004.1 | PLATFORM: Mac & Win
Published On: October 6, 2006

When compiling your code, 4D adds the name and type of every variable to its symbol table and initializes
variables only. Arrays are not initialized until they are created with the ARRAY commands (e.g. ARRAY TEXT).

This is why the Size of Array function cannot be used to detect if an array has been created in compiled code. This command will return whatever value exists in the 4 bytes that store the size of the array but, since the array has not yet been created, this value can and will be wrong.

Instead use the Type function. Even compiled, Type will return 5 (Is Undefined) for an array until the code that creates it is executed.