Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jamie Osborn
  Where is Jamie Osborn?
 Melbourne
 Australia
 Jamie Osborn
 To: Nathan Gloyn
  Where is Nathan Gloyn?
 Torquay
 United Kingdom
 Nathan Gloyn
 Tags
Subject: RE: Passing cursors around
Thread ID: 33686 Message ID: 33691 # Views: 0 # Ratings: 0
Version: Visual FoxPro 6 Category: Forms
Date: Tuesday, December 02, 2003 2:24:46 AM         
   


> Can I create a form method that allows me to create a cursor and pass it to another form method much like you can with an ADO recordset within VB?
>
> If not what is the best way to accomplish this type of functionality within VFP?
>
> Nathan

As long as forms are in the same datasession you don't need to pass cursors around. Cursors aren't "scoped" to methods etc. They are scoped to datasessions. Therefore you only need to pass the alias around. eg.
*-- My main method
*-- Get a unique alias 
lcTempCursor = "w" + SYS(2015)

SELECT * ;
  FROM MyTable ;
INTO CURSOR (lcTempCursor) READWRITE && may only need NOFILTER

thisform.DoSomething(lcTempCursor)

WAIT "Wow - something was done to my cursor !!!" WINDOW
RETURN

**************
* DoSomething method
**************
LPARAMETERS tcAlias

LOCAL lnSelect

lnSelect = SELECT() && Good practice to store the current work area and restore it at the end of a method

SELECT(tcAlias)
SCAN
  *-- Do something to each record
ENDSCAN

SELECT(lnSelect) 

RETURN


Cheers,
Jamie
jamie.osborn@foxite.com

ENTIRE THREAD

Passing cursors around Posted by Nathan Gloyn @ 12/1/2003 10:30:02 PM
RE: Passing cursors around Posted by Chan Kok Kiet @ 12/2/2003 1:04:43 AM
RE: Passing cursors around Posted by Jamie Osborn @ 12/2/2003 2:24:46 AM
RE: Passing cursors around Posted by Nathan Gloyn @ 12/2/2003 9:53:49 PM