Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to pass cursor between two forms?
Message
From
26/10/2004 08:50:21
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00954505
Message ID:
00954512
Views:
15
>Hello,
>
>I have form with DataSession=2 (Private data session).
>Now I want to call another form which will be able to access cursor in first form. Is it possible to do without changing property DataSession to 1 (Default data session)?
>
>Thanks in advice


Hi There :)

I developed set of functions
for resolving this problem.

In first form using function 'deflate'
you create special (public) object
holding cursor data in it's properties
public oData
oData=deflate(cSourceAliasName)
In second form
you call counter function 'inflate' passing that object
as parameter, and function creates cursor residing in that form.
=inflate(oData,cTargetAliasName)
Source for these two functions
is below coupled by class for creation
of 'datacarrier' object
function deflate
    lparameters cAlias,cCondition
    local cAlias,cCondition
    local oTable,cAlias,cCondition
    oTable=createobject('table_parser',cAlias,cCondition)
    return oTable



function inflate
    lparameters oTable,cAlias,cEmpty
    local oTable,cAlias,cEmpty
    local aa(1)
    local bb(1)
    =acopy(oTable.arrstru,aa)
    if type('cEmpty')= 'L'  &¬ passed
       =acopy(oTable.arrdata,bb)
    endif   
    create cursor &cAlias from array aa
    select (cAlias)
    if type('cEmpty')= 'L'  &¬ passed
       append from array bb
    endif   
    oTable=.f.
    return .t.


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
Only small problem is that memos are not passed at the moment
so u will hv to upgrade them for doing so.

Rgds++
*****************
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