>thanks cetin.
>
>my problem with local is displayed from this quote from MSDN:
>
>"Local variables and variable arrays can be used and modified only within the procedure or function in which they are created, and cannot be accessed by higher- or lower-level programs. Local variables and arrays are released once the procedure or function containing the local variables and arrays completes execution."
>
>it is only available within the program that it is being used. I often need a variable in another program or function and often need the result from a function in more than one program. Can I make local variables available to these programs without declaring them as public?
>
>thanks,
>
>paul
Sort of yes. Instead of making them public you pass and return parameters. There is one public IMHO in VFP - public oApp (which is created in main.prg and is a custom 'application' object). Here is a piece of code:
Local Array laMonth[7,7]
Local ix
For ix=1 To 12
GetDaysOfMonth(m.ix,2006,@laMonth)
oForm.displayMatrix(@laMonth,Cmonth(Date(2006,m.ix,1)))
Endfor
laMonth and ix are local array and variable. However they're passed (array by reference) to other functions/methods as parameters. If one of those functions/methods would return something again it'd be local to them. ie:
function myFunction(taArray,tnSomeValue)
local loSomeObject
* do somethign with array using tnValue
* initialize and update loSomeObject
return loSomeObject
Within a class properties would be an easy way to keep your variables that need to accessed by most of the methods. ie:
define class mySomething as custom
BaseMultiplier = 1
CurrentNode = null
procedure processNode
if !isnull(this.currentNode)
endif
endproc
procedure processNodes
local loNodes,ix
for ix=1 to loNodes.Length
this.currentNode = loNodes[m.ix]
this.processNode()
endfor
endproc
enddefine
Cetin