Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scope in VFP
Message
From
28/07/2006 12:11:53
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
28/07/2006 11:53:27
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
SAMBA Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01141152
Message ID:
01141199
Views:
19
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform