Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursor as an object
Message
From
25/07/2003 11:20:14
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00809437
Message ID:
00813514
Views:
19
>Hi,
>
>Its late Friday and my memory is blank.
>Can you pass a cursor as an object?
>
>
>Thanks, J

Hi J :-))

Well, it can be done parsing cursor data as object properties
for 'smuggling' smaller cursors between different datasessions.
Never tried with COM/DCOM.

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 session 'server' uses function 'deflate'
to 'pack' data 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')
.
.
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

function inflate
    lparameters oTable,cAlias,cEmpty
    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.



function deflate
    lparameters cAlias,cCondition
    local cAlias,cCondition
    local oTable,cAlias,cCondition
    oTable=createobject('table_parser',cAlias,cCondition)
    return oTable
- Problems:
1. Volume of data cannot exceed memory limits of an OBJECT/ARRAY
2. Does not parses 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
Next
Reply
Map
View

Click here to load this message in the networking platform