Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Handling Tables
Message
 
To
22/01/2004 09:39:47
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00868831
Message ID:
00869625
Views:
24
Thanks for your interest! At your request, I have provided more details on what the VFP program I wrote does, and shortened the code to only what worked.
The below problem, involves “inverting” the values in one table to another, e.g., making the 1st record in one table the last in another and so on. In other words, the data I get from a Yahoo download has the most current data in the 1st row of the table & I want it last for my models.

My basic question though has to do with when and under what circumstances you use the “&” macro substitution and when you use its VFP counterpart, the “()”. The VFP Reference says “avoid” use of the “&”, but after extensive trial & error, I found that I had to use the “&”.
Here’s the successful VFP code I wrote to “invert” the data. Downloaded table has two fields: Date & Value. Code is abbreviated & only refers to moving the data between the two tables.
What I really want is to know how the code can be improved with respect to the use of the “&”

Parameters m.lcfil &&name of table to be inverted, passed from elsewhere.
SET MULTILOCKS ON
SELECT 1 &&wk area a
USE (lcfil)
COPY STRUCTURE EXTENDED TO hdr
SELECT 2
USE hdr
GO 2
m.lcfldnm1=FIELD(5)
replace &lcfldnm1 with .t. &&makes new table accept null values
CREATE temp from hdr
ERASE hdr.dbf
SELECT 2
USE temp
SELECT a
m.lircdcnt=RECCOUNT(1)
SELECT b
FOR m.icnt = 1 TO m.lircdcnt
APPEND BLANK &&puts blank recordes = number of table to be inverted
ENDFOR
GO top
CURSORSETPROP("Buffering",5)
SELECT a
FOR m.lifldcnt = 1 TO FCOUNT() && loop for each field in turn
GO bottom
DO WHILE m.lircdcnt => 1 && loop for each record in the field
m.lcfldnm1=FIELD(m.lifldcnt)
SELECT b
m.lcfldnm2=FIELD(m.lifldcnt)
replace &lcfldnm2 WITH a.&lcfldnm1 && accepted
SKIP 1
SELECT a
m.lircdcnt = m.lircdcnt - 1
SKIP -1
ENDDO
m.lircdcnt=RECCOUNT(1)
SELECT b
GO top
SELECT a
ENDFOR
Use
Select b
Tableupdate(.t.)
Use
Return
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform