Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I determine scope of an existing variable?
Message
 
 
To
17/10/2002 18:51:49
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00712455
Message ID:
00712653
Views:
11
Hi David,

I think, you're on the right track. Let me know the function, you'll come with.

Good luck!

>Hi Nadya,
>
>Thanks. In the meantime, I tried:
>
>save to somefile all like somevariable
>
>It creates a smaller file than:
>
>display memory like (tuvariable) to file (lcfile)
>
>Now I have to see if I can figure out the format of the 'save to' file, to see if I can extract the variable scope info. I'm guessing that save to will execute faster than display memory, but it's just a guess.
>
>
>
>
>>That seems to be the only way, unfortunately. You can always check type of variable to see, if it's visible in the current procedure, but it doesn't give you the scope.
>>
>>>I have begun maintenance work on a large vfp system (converted from 2.6) where the naming conventions of using the first letter for the variable scope and the second letter for the data type are not adhered to. When looking at the code I have no way of knowing the variable scope, unless I trace through lots of code looking for local, private or public declarations. I don't even know if the variable in question is a memory variable or reference to a table column.
>>>
>>>I have not found any function that lets me test the scope, e.g., something like:
>>>
>>>lcretval=varscope(somevariable)
>>>
>>>where return values could be PUBLIC, PRIVATE, HIDDEN, LOCAL, OR TABLEFIELD
>>>
>>>
>>>endproc
>>>
>>>The only way I can think of to do this would be to do something like:
>>>
>>>function varscope
>>>lparameters tuvariable
>>>local lcfile
>>>lcfile=sys(2015)
>>>display memory like (tuvariable) to file (lcfile)
>>>** then have code to parse lcfile, looking for 'Pub', 'Hidden', etc.
>>>** then store the value and return it.
>>>
>>>erase (lcfile)
>>>
>>>
>>>
>>>endfunc
>>>
>>>This seems very klugey, and I'm guessing it won't execute very fast. But I don't know how else it could be done.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform