Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What are the ground rules for using LOCALs and STATICs?

ground locals rules
0
Posted

What are the ground rules for using LOCALs and STATICs?

0
10

LOCALs and STATICs must be the first statements in a function, except possibly for the PARAMETERS statement. They may be declared with initial values (e.g. LOCAL a := 1), but STATICs may not be initialized with a value that is unknown to the compiler (e.g. STATIC b := myfunc()–where myfunc is the name of your user-defined function–is invalid). The initialization is performed every time the function is called (in the case of LOCALs) or once at the beginning of the program (in the case of STATICs). If you want to use a file-wide STATIC variable to share information among functions within the same source module, that module must be compiled with the /n switch, and the STATIC declarations must precede the first FUNCTION or PROCEDURE.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.