Niki, Sounds like you have worked things out and you got a lot of good help but there are a couple of things that might be helpful for you as a student.
At one point someone posted that you do something like:
USE C:\MYPROJECT\DATA\SGG _FINAL AS Stock
That is incorrect and will generate an error. It should be:
USE C:\MYPROJECT\DATA\SGG _FINAL alias Stock
In a dBase (i.e. FoxPro) "use" statement, if you want to refer to the table by a different name, then you use the keyword "alias".
You might do this for several reasons, such as opening the table a second time. Then you would use an alias.
For example if you wanted to open a table named MYTABLE twice you would have to use an alias and use the "again" keyword. So you might say
Code:
use MYTABLE
select 0 && selects the next available work area
use MYTABLE again alias MYTABLE2
If you don't use the word "alias" the system assigns the table name as the alias. So the alias of the first instance is simply MYTABLE
The VFP (i.e. dBase) "select" word tells the system which work area is the default work area. This way you don't have to prefix a field name
with its alias when you're in that table's work area.
The "as" word is good in an SQL select statement (although you really don't need it there either.)
For example in an SQL statement involving 2 tables, MYTABLE and YOURTABLE, both having key fields named PRIMEKEY, and both having fields named FIELD1 and FIELD2 you could say
Code:
select m.FIELD1, m.FIELD2, y.FIELD1 as F1, y.FIELD2 as F2 from MYTABLE as M, YOURTABLE as Y where m.PRIMEKEY = y.PRIMEKEY && this is an inner join using "where"
OR you can omit the "as" keyword like this
select m.FIELD1, m.FIELD2, y.FIELD1 F1, y.FIELD2 F2 from MYTABLE M, YOURTABLE Y where m.PRIMEKEY = y.PRIMEKEY
The result would be a query with these columns:
FIELD1 FIELD2 F1 F2
..... ...... ..... .....
But you can't use the "as" keyword in a foxpro "use" statement.
One other thing I noticed was the use of the "then" keyword in an "if else endif" construct.
VFP does permit it but it's not a normal dBase language thing and VFP is a dBase language.
So shoot me, but I think one should avoid using unnecessary keywords. It just clutters up the source code.
Along those lines, some people are in the habit of using keyword abbreviations. dBase has always permitted that
but this is one of things where just because you CAN do it, doesn't mean that you SHOULD do it. In the early days of
8 bit computers, 64K of memory and 360K floppy disks that seemed important but it's far more important that your code
should be neat, clear, and with a consistent style standard and indentation practice. So I would recommend never to
abbreviate keywords. Clarity is paramount in source code, IMO.