Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FoxPro 2.6 for Dos use of memory variables

Status
Not open for further replies.

wpeters

Programmer
Feb 23, 2009
1
US
HELP! I have been thrown into being a developer of an OLD system. I have done well with the knowledge I have thus far. EXCEPT, cannot find reference books, not too many forums out there. I need a quick breakdown of use of memory variables. Why did the previous programmer sometimes use m-> and sometimes a->?
 
Value 'containers' (a.k.a. "variables") can be of a variety of types. Typically these are memory variables (which reside soley in the workstation's memory) and data table fields (which reside in a FP data table).

The OLD symbology of -> is synonymous with the newer symbology . (or 'dot').
Code:
Example:
   m->ThisValue
   m.ThisValue   && same as above

The m-> or m. was used to designate a memory variable - again resident in the workstation memory ONLY.

When a data table is used, its ALIAS is typically used to indicate a value from one of its fields. These values are typically shown as ALIAS + '->' + Fieldname or ALIAS + '.' + Fieldname
Code:
Example:
   USE MyTable IN 0
   SELECT MyTable
   m.MemVariable = MyTable.FldValue

This symbology comes in very handy if you should have both a memory variable and a data table field with the same name. How would you differentiate between the two and know when you were using which? Now you have a way.

From your example you have some data table which is aliased as 'A' either by workspace inheritance or by filename. And values referenced as A-> are data table field values.

Good Luck,
JRB-Bldr




 
To add to JRB-Bldr's post, the A-> notation stems from the old Fox days when there was a limit of 10 available work areas, or more specifically, open tables and index files.

You would open tables by specifying a work area by using:
SELECT 1
USE somedbf1
SELECT 2
USE somedbf2

and so on up to 10.

But in order to reference a field in the non-current work area, you couldn't use:

REPLACE 1.field1 WITH 'asdf'

you had to use the alpha version of the work area. So you would use:

REPLACE A->field1 WITH 'asdf' .

Most people found it easier to just reference the work areas with the letter:

SELECT A
USE somedbf1
SELECT B
USE somedbf2

etc., up to 'J'.

Since 'M' was beyond the limit of work areas, it would never be used as a work area to open a table, so it was always safe to use for memory variables. Which means you can pretty much assume any alpha character 'J' or lower, will be a table reference.



-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top