Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
Subject: RE: Create 2 Dimensional Array from Cursor
Thread ID: 101081 Message ID: 101182 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Wednesday, July 12, 2006 3:56:25 PM         
   



> > > > > Hi,
> > > > >
> > > > > This maybe a stupid question, but my brain is fried today.
> > > > >
> > > > > I have a simple cursor open with my record pointer pointing on
> > > > > a record. This cursor was make from a SQLEXEC() call to a SQL-Server
> > > > > backend.
> > > > >
> > > > > I am kicking myself as there is probably a simple way to do this.
> > > > > I want to create a 2 dimensional array, where the first component is
> > > > > the field names, and the second conponent is the actual values in the
> > > > > field.
> > > > >
> > > > > Anyone got any ideas, as I am fresh out.
> > > > >
> > > > > Pete from the Great White North. (Only in Canada, ay.) Over and Out ...

> > > >
> > > > FOR i = 1 TO FCOUNT()
> > > >    DIMENSION aCursor[i,2]
> > > >    aCursor[i,1] = FIELD(i)
> > > >    aCursor[i,2] = EVALUATE(FIELD(i))
> > > > ENDFOR
> > > > 

> > > >
> > > > -BP
> > > > www.peisch.com

> > >
> > >
> > > Hi Barbara,
> > > Yeppers that does it.
> > > Ken's solution works as well, but your code is tighter.
> > > Pete from the Great White North. (Only in Canada, ay.) Over and Out ...

> >
> > Actually, both mine and Ken's code are pretty much the same. He specified the alias and I didn't. But he also had only one dimension statement before the loop, which I think is better.
> >
> > -BP
> > www.peisch.com
>
>
> Hi,
> I ponder at the location of the dimension statement?
> The statement inside the loop seems only to add the the
> array, rather than recreating it over and over again.
> Mechanically, I am not 100% as to what is really happening?
>
> Pete from the Great White North. (Only in Canada, ay.) Over and Out ...

Pete,

I think you are correct - it only adds to the array. Mine is probably a throwback to the days when dinosaurs roamed the earth and you had to declare the array size before you could use it. I never fell out of that habit.

As to the alias, I tend to like to explicitly add the alias - it is far less dangerous, especially with a command like ZAP.

Ken

You shall know the truth - and the truth shall set you free. (John 8:33)

ENTIRE THREAD

Create 2 Dimensional Array from Cursor Posted by Pete Sass @ 7/11/2006 8:21:13 PM
RE: Create 2 Dimensional Array from Cursor Posted by Ken Murphy @ 7/11/2006 8:26:35 PM
RE: Create 2 Dimensional Array from Cursor Posted by Barbara Peisch @ 7/11/2006 8:39:38 PM
RE: Create 2 Dimensional Array from Cursor Posted by Pete Sass @ 7/12/2006 4:18:36 AM
RE: Create 2 Dimensional Array from Cursor Posted by Barbara Peisch @ 7/12/2006 6:17:43 AM
RE: Create 2 Dimensional Array from Cursor Posted by Pete Sass @ 7/12/2006 3:49:24 PM
RE: Create 2 Dimensional Array from Cursor Posted by Ken Murphy @ 7/12/2006 3:56:25 PM
RE: Create 2 Dimensional Array from Cursor Posted by Barbara Peisch @ 7/12/2006 9:48:02 PM