KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: In Interpreted Mode be aware of late declaration of form variables
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: September 2, 2011

In Interpreted Mode be aware of late declaration of form variables.

It is a great practice to declare all 4D form variables early in the initialization of a form. It is best to either declare all the form variables early in the method that opens the form, before the call to DIALOG, or in the On load form method event handler.

Why is this important?

Assume there is a variable on the form named MyReal_R. Its intended use is as a Real number, but the compiler directive C_REAL(MyReal_R) is not called until after the form has be open to the user for a period of time.

If the user enters a value into the variable and subsequently the compiler directive is called, the value entered by the user will be changed to its initialization value by the compiler directive, in this case zero.

This is not a issue in a compiled application because the compiler preinitializes all form variables.