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!

Put table fields values into array 2

Status
Not open for further replies.

Paco75

Programmer
Joined
Oct 11, 2001
Messages
239
Location
US
Hi,

is there a command in visual foxpro that can return all fields into a array?

thanks
 
I agree, Dave.

But I'm curious now. Olaf, why is SCATTER NAME "better" than SCATTER TO array? Both use a single memory variable, but one has the overhead of creating an object. Why is it intrinsically better?

There are places where I would definitely prefer SCATTER NAME, for sure, but not when the original request was to create an array. How is it intrinsically better to create an object?
 
dan,

For one, I prefer an object for easier inspection in the debugger, you have field names as property names, not just a bunch of array elements.

An array suggests you can use APPEND FROM ARRAY, but that will not work with MEMO fields. you can of course INSERT FROM ARRAY or GATHER MEMO, no question. With an object you can GATHER and also INSERT INTO ... FROM NAME loRecord.

In special cases, it's handy to SCATTER ADDITIVE to add properties to the one object, that's not possible with an array.

It has some advantages, don't you think? It might cost a little bit more time, but I don't think of it as an overhead.

Bye, Olaf.
 
Yes, I did say there are places I prefer SCATTER NAME too. Of course, none of that was in play here.

What ever happened to answering the questions that people actually ask instead of the ones we imagine? ;)
 
dan,

sometimes we know better, don't we? Such a very low level specific question often means a misunderstanding of basic concepts.

In this case it turns out that swapping records was the overall goal, which I think is an invalid operation, as a table is meant as a set of data and the physical order of fields or records is of no interest at all. Tables are for persisting data. No more, no less.

For presenting data in a GUI you do query the data in the form you need to present, but in the database it's merely a set of data.

This is not to say I force anyone to live by that rules, but it saves troubles. And the moment I smell something wrong, I do argue for a better approach, what's wrong with that?

Bye, Olaf.
 
I reckon this thread probably could have all been summed up with something like this then:

Take a look at the VFP help on SCATTER. There are a few good examples in there.

"SCATTER Command

Copies data from the current record to a set of variables, to an array, or an object.

SCATTER and COPY TO ARRAY behave similarly. SCATTER copies only a single and current record into an array or a set of variables and automatically creates the array or variables if they do not already exist. COPY TO ARRAY copies multiple records into an array. For more information, see COPY TO ARRAY Command."

We must be bored. [wink]


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

Part and Inventory Search

Sponsor

Back
Top