[AccessD] Static Function Tutorial (was Like Operator SQL Syntax)

Stuart McLachlan stuart at lexacorp.com.pg
Sat Jun 7 18:32:35 CDT 2003


On 7 Jun 2003 at 16:22, Arthur Fuller wrote:

> Static functions contain variables whose value is preserved between calls.
> More precisely, static variables retain their values. By default all
> variables in a static function are static variables. You could declare a
> static variable in a non-static function, but I don't know why you would. 
>  
As an accumulator to tell you how many times the function is called?
For a variable that is very slow to calculate in a function that you 
are going to call many times in a row (say something that uses lots 
of DLookups or DSums etc) but won't change during the sequence of 
calls?

Hre's one that uses both

Function MyFunction() as long
Static timescalled as long
Static myhardtocalcuatevariable
If timescalled = 0 then
   myhardtocalculatevariable = ......
End If
 timescalled = timescalled + 1
.........
End Function



-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System Support.





More information about the AccessD mailing list