Froggerprogger wrote:You could do it this way:
Code: Select all
Procedure MyProc()
Static a.l, b.l, c.l
Static isInitialized.l
If isInitialized = 0
a = 992
b = 12*a
c = 111
isInitialized = 1
EndIf
; some code
EndProcedure
Correct, I can do that
if I know for certain that PB sets up all static vars to zero. If not, the first time the function is called the values for all static vars (including isInitialized) would be undefined. A simple test such as the code you present
might indicate that statics are set to zero, but this would only be an assumption until Fred says otherwise... And I can't rely on an assumption. Static vars being set to zero (or "" in the case of strings) is not documented, thus subject to change at any time.
Also, not being able to set those values at compile time means that the isInitialized check has to be performed every time the function is called and is unnecessary overhead.
Matthew