KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: The importance of early declaration of variables
PRODUCT: 4D | VERSION: 13.2 | PLATFORM: Mac & Win
Published On: March 21, 2013

A basic but crucial point of attention when working with variables of any type is to make sure that a variable be either declared using one of 4D's Compiler declaration commands or have been "touched" by giving it a value before it is used in an expression.

Consider the form shown below...



The button labeled "Test" containes the following expression:

Tot_L:=Var01_L+Var02_L+Var03_L


When executed the error shown below is produced.



Notice in the Debugger, shown below, only one of these variables shown in the list of process variables is Tot_L. Tot_L is displayed because it has been "touched" by the "gets" assignment, ":=". None of the other variables have been declared or touched before being used in this expression.

To aviod this error these variables need to have been earlier declared in the process using the C_LONGINT command or have a value previously assigned to them.