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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scatter/gather to an array

Status
Not open for further replies.

LindaRichard

Programmer
Feb 23, 2001
103
0
0
CA
I use the following code to scatter a series of
records for a view I created from a larger table ar_raw

PUBLIC giNberofRawToKeep
select tmp_monraw
giNberofRawToKeep=RECCOUNT()
PUBLIC ARRAY gmRawToKeep(giNberofRawToKeep)
GO top
FOR t=1 TO giNberofRawToKeep
SCATTER NAME gmRawToKeep(t)
SKIP 1
NEXT t

I then perform some calculations that modify the values
in ar_raw. Sometimes I need to reset these values.
So I have the following code. My problem is referencing
a specific field to search on it

SELECT ar_raw
FOR t=1 TO giNberofRawToKeep
&&can't figure out how to reference the field argonraw in the scattered variable
LOCATE FOR ar_raw.argonraw=gmRawToKeep(t).argonraw
IF FOUND()
gather NAME gmRawToKeep(t)
endif
NEXT t

I have used table buffering before but in this specific
case I simply want to search full records and restore
them my self.

Thanks for your help.

Linda




 
You're trying to crossbreed two different functions here.
SCATTER MEMO NAME .... creates an object with properties corresponding to table fields.
But what you're trying to do, scan through a table and add items to an array, is a different scenario.

What you may want to try is something like:
Code:
SELECT * FROM MyTable INTO ARRAY gmRawToKeep
STORE _TALLY TO giNberofRawToKeep
The array will then contain the items you need.



-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Linda,
That syntax seems to work for me, what seems to be the problem? Are you getting a compile syntax error? A runtime syntax error? The wrong results?

I am curious why you wouldn't just use a cursor rather than an object in an array row? While it would take a bit more code, I don't believe there would be any noticable difference unless you are handling a lot of records, then you'll run into array limits problems anyway (at least till VFP 9.0! <g>)

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top