Two forms share a variable? 
Author Message
 Two forms share a variable?

I have an application in which one form needs to read information that
is available in another form (could be placed in a variable). Last
night I tried several things and couldn't figure out how to accompilsh
this.

Does anyone have any ideas?

--

OPCOM: Solaris 2.x Migration Support         _-\_<,  

                                         =-=-=-=-=-=-=



Wed, 03 Jul 1996 02:25:40 GMT
 Two forms share a variable?


Quote:
>I have an application in which one form needs to read information that
>is available in another form (could be placed in a variable). Last
>night I tried several things and couldn't figure out how to accompilsh
>this.
>Does anyone have any ideas?

There are two ways to share information between forms:  1) library 2) form

The following methods describe the form method of sharing variables.  Form1 is
the master form, form2 is the detail form:

form2::method XferValue() anytype
  return MyValue
endmethod

form1::Uses ObjectPAL
        method XferValue() anytype
endUses

form1::method pushbutton(var eventInfo Event)
var
  f form
  x anytype
endvar
        f.open("form2")
        x = f.XferValue()
        ;At this point, X now holds the value you wanted to get from form2
        ;NoTE: the f.open() could have been replaced with an f.attach() if  
        ;the other form was already open
endmethod

Good luck

--
                    Limax Computing - Paradox Questions?




Wed, 03 Jul 1996 06:46:19 GMT
 Two forms share a variable?

: I have an application in which one form needs to read information that
: is available in another form (could be placed in a variable). Last
: night I tried several things and couldn't figure out how to accompilsh
: this.

: Does anyone have any ideas?

Any ObjectPal code (in a library, script, or form) can access the values in
fields of an open form by first attaching to the open form and then using
the dot notation with the names of the fields in the form.  Two details to
observe are: 1) to attach to an open form, you need to know the title of
the open form, and 2) the name of the field in the open form is the name of
the field object, not the name of the corresponding field in the database
table.  A typical scenario is

var
   frm Form
endvar

frm.open("otherFormName")
frm.wait()
msgInfo("", "The value in the XYZ field is " + frm.XYZ.value)
frm.close()

In this scenario, there was no need to explicitly attach to the open form,
since the frm variable was used to open the form in the first place.

Dan Milliron



Wed, 03 Jul 1996 07:57:46 GMT
 Two forms share a variable?


  > (Gil Hauer - OpCom Consultant) writes:

 >> I have an application in which one form needs to read information
 >> that is available in another form (could be placed in a
 >> variable). Last night I tried several things and couldn't figure
 >> out how to accompilsh this.

 >> Does anyone have any ideas?

  > There are two ways to share information between forms: 1) library
  > 2) form

  > The following methods describe the form method of sharing
  > variables.  Form1 is the master form, form2 is the detail form:

  > form2::method XferValue() anytype return MyValue endmethod

  > form1::Uses ObjectPAL method XferValue() anytype endUses

  > form1::method pushbutton(var eventInfo Event) var f form x anytype
  > endvar f.open("form2") x = f.XferValue() ;At this point, X now
  > holds the value you wanted to get from form2 ;NoTE: the f.open()
  > could have been replaced with an f.attach() if ;the other form was
  > already open endmethod

  > Good luck

  > -- Limax Computing - Paradox Questions?  / o \ / E-Mail:


Actually, I was trying to go the other way; that is, form2 needs the
value from form1 (the owner of form2).

The situation I have is that form1 opens form2 and it is form2 that
needs the value.

--

OPCOM: Solaris 2.x Migration Support         _-\_<,  

                                         =-=-=-=-=-=-=



Wed, 03 Jul 1996 09:26:10 GMT
 Two forms share a variable?


Quote:


>  > (Gil Hauer - OpCom Consultant) writes:
> >> I have an application in which one form needs to read information
> >> that is available in another form (could be placed in a
> >> variable). Last night I tried several things and couldn't figure
> >> out how to accompilsh this.
> >> Does anyone have any ideas?
>  > There are two ways to share information between forms: 1) library
>  > 2) form
>  > The following methods describe the form method of sharing
>  > variables.  Form1 is the master form, form2 is the detail form:
>  > form2::method XferValue() anytype return MyValue endmethod
>  > form1::Uses ObjectPAL method XferValue() anytype endUses
>  > form1::method pushbutton(var eventInfo Event) var f form x anytype
>  > endvar f.open("form2") x = f.XferValue() ;At this point, X now
>  > holds the value you wanted to get from form2 ;NoTE: the f.open()
>  > could have been replaced with an f.attach() if ;the other form was
>  > already open endmethod
>  > Good luck
>Actually, I was trying to go the other way; that is, form2 needs the
>value from form1 (the owner of form2).
>The situation I have is that form1 opens form2 and it is form2 that
>needs the value.

form1::method pushButton(var eventInfo Event)
var
  f form
endvar
  f.open("form2")
  f.MyFieldonForm2 = MyFieldonForm1
  f.wait()
  f.close()
endmethod

If you are not placing the value in a field, but rather in a variable, change
the declaration of the XferValue() method to receive a value, not pass one
back:

form2::method XferValue(var MyValue anytype)
  MyValueonForm2 = MyValue
endmethod

That should do it.

--
                    Limax Computing - Paradox Questions?




Thu, 04 Jul 1996 01:26:17 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. Sharing variables between forms

2. Variable from Access 2K form to an SP with two returns

3. two forms and object variable not set

4. SHARED VARIABLE not really SHARED???

5. How much sharing in shared forms?

6. Two measure form two fact tables

7. Pass global variable from form to form

8. Form to Form Variables

9. Two connections sharing temporary table

10. Two Databases Share Common Table?

11. Two databases sharing the same files?

12. Sharing tables from two Delphi programs


 
Powered by phpBB® Forum Software