****************************************************** * Sample of passing cursor between two VFP (data)sessions * by storing cursor data into object * Author Djordjevic Srdjan ****************************************************** . use ...\data\yourtable.dbf in 0 shared ... . local oBO,oCursor oBO=createobject('TestBo') oCursor = cur2obj('YourTable') &&call to function (Amend cursor name accordingly) oBO.consume_data(oCursor) ****** Test Session (private) define class TestBo as session procedure init set deleted on this.open_tables() procedure open_tables * * procedure consume_data lparameters oCursor =obj2cur( oCursor ,'CursorOnTarget') && call to function browse normal enddefine ****************************** * Store Cursor to object. * In fact, Creates Parser object and tells him to * suck in cursor and then returns it all back to caller. ****************************** function cur2obj lparameters cAlias,cCondition local oTable,sv_alias sv_alias=alias() select (cAlias) oTable=createobject('table_parser') oTable.cur2obj(cAlias,cCondition) select (sv_alias) return oTable ****************************** * Restore Cursor from object ****************************** function obj2cur lparameters oTable,cAlias local lArray(1) create cursor &cAlias from array oTable.arrstru select (cAlias) if !oTable.HaveRecords return endif =acopy(oTable.arrdata,lArray) select (cAlias) append from array lArray if oTable.MemoCount=0 return endif local cMemoName,cMemoContent local i,j go top scan nMemoRec=recno() j=0 for i=1 to alen(oTable.arrstru,1) if oTable.arrstru(i,2) = 'M' j = j + 1 cMemoName = cAlias+'.' + oTable.arrstru(i,1) cMemoContent = oTable.arrmemo(nMemoRec,j) if type('cMemoContent') = 'C' replace &cMemoName with cMemoContent endif endif next endscan go top ********************** define class table_parser as custom OriginalAlias='' HaveRecords=.t. MemoCount=0 declare arrstru(1) declare arrdata(1) declare arrmemo(1) procedure cur2obj lparameters cAlias,cCondition local a_array,b_array select (cAlias) go top this.OriginalAlias = cAlias declare a_array(1) =afields(a_array) acopy(a_array,this.arrstru) this.MemoCount = this.count_memo_fields() if eof() this.HaveRecords=.f. return endif if type('cCondition') <> 'C' cCondition = ' .t. ' endif create cursor tmpCursor from array a_array select (cAlias) scan for &cCondition scatter memvar memo insert into tmpCursor from memvar endscan select tmpCursor go top if this.MemoCount > 0 declare this.arrmemo(reccount('tmpCursor') , this.MemoCount ) local i,j scan nMemoRec=recno() j=0 for i=1 to alen(this.arrstru,1) if this.arrstru(i,2) = 'M' cMemoName = 'tmpCursor.' + this.arrstru(i,1) j = j + 1 this.arrmemo(nMemoRec,j)= &cMemoName endif next endscan endif select tmpCursor go top declare b_array(reccount('tmpCursor') , alen(a_array,1) ) copy to array b_array =acopy(b_array,this.arrdata) use procedure count_memo_fields local i,j j=0 for i=1 to alen(this.arrstru,1) if this.arrstru(i,2) = 'M' j=j+1 endif next return j enddefine ***********************************************************>