Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing Cursor to Form
Message
From
02/07/2004 06:15:57
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00913299
Message ID:
00920036
Views:
12
>Hi,
>
>Can I pass a cursor to another form? I usually work with 'Private Data Session'.
>
>Regards,



Hi there :)

Well, it can be done parsing cursor data as object properties,
for 'smuggling' smaller cursors between different datasessions.

I constracted one special object (class)
serving me as sort of 'datacarrier'
having two arrays; one for carrying structure of
cursor and second actual data.

Then using two fuctions calls I am able to parse
cursors back and fourt betweeen datasessions.

So (data)session 'server' uses function 'deflate'
to 'pack' cursor into object
.
.
oCursor = deflate('SourceCursor' , 'recno() < 5' ) 
.
.
while function 'inflate' is used to populate final
destination cursor in 'client' datasession.
.
.
procedure receive_data
lParameters oData
=inflate(oData,'resultCursor')
.
.
Here comes source;
*******************************************
* function deflate
* Used to populate object
* carrying source cursor data/structure
********************************************
function deflate
    lparameters cAlias,cCondition
    ******* cAlias      && Source Alias
    ******* cCondition  && Optional condition 

    local cAlias,cCondition
    local oTable,cAlias,cCondition
    oTable=createobject('table_parser',cAlias,cCondition)
    return oTable


**************************
* function inflate
* Used to create result cursor
* in target datasession 
**************************
function inflate
    lparameters oTable,cAlias,cEmpty

    ******* oTable  && Object carrying source cursor in it's properties 
    ******* cAlias  && Result cursor  Alias Name 
    ******* cEmpty  && String 'EMPTY' causes empty cursor to be populated
  
    local oTable,cAlias,cEmpty
    local aa(1)
    local bb(1)
    =acopy(oTable.arrstru,aa)
    if type('cEmpty')= 'L'  &&not passed
       =acopy(oTable.arrdata,bb)
    endif   
    create cursor &cAlias from array aa
    select (cAlias)
    if type('cEmpty')= 'L'  &&not passed
       append from array bb
    endif   
    oTable=.f.
    return .t.


***************************************************
* Class table_parser used to instantiate 
* Objects serving as cursor data/structure carrier
***************************************************
define class table_parser as custom
    original_alias=''
    declare arrstru(1)
    declare arrdata(1)


    procedure init
        lparameters cAlias,cCondition
        local cAlias,cCondition
        this.prepare(cAlias,cCondition)

    procedure prepare
        lparameters cAlias,cCondition
        local cAlias,cc
        select (cAlias)
        this.original_alias = cAlias
        declare cc(1)
        =afields(cc)
        acopy(cc,this.arrstru)
        release cc
        select (cAlias)
        if type('cCondition') <> 'C'
               copy to array cc
               acopy(cc,this.arrdata)
         else
            if cCondition <> 'EMPTY'         
               copy to array cc for &cCondition
               acopy(cc,this.arrdata)               
            endif   
        endif




enddefine
- Problems:
1. Volume of data cannot exceed memory limits of an OBJECT/ARRAY
2. Does not 'carry' memos at the moment but it can be arranged.


Hv nice weekend :-))
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Previous
Reply
Map
View

Click here to load this message in the networking platform