dbTalk Databases Forums  

VFP 7.0 Help

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss VFP 7.0 Help in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ShahJagat
 
Posts: n/a

Default VFP 7.0 Help - 09-21-2003 , 01:33 PM






Hi -

I am working on migrating a FPW 2.6 application to VFp. I am very new at VFP.

I am trying to create a form that would return a value that the user inputes
into a text box.

Do form' Myform.scx' to cUserValue

In the form, I have a Text box. 'Text1'.

In the unload event of the form, I have the following two lines of code.

*form unload()
retval=thisform.Tex1.Value
Return retval.

This does not work. When I look at the trace window, it runs into an error at
the line 'retval=thisform.Text1.Value'.
For whatever reason the text1.value is not visible at the form unload event.

What am I dong wrong? I am ready to tear my hair out.

Shah

Reply With Quote
  #2  
Old   
Rick Bean
 
Posts: n/a

Default Re: VFP 7.0 Help - 09-21-2003 , 02:07 PM






Shah,
Since only a Modal Form can return a value, make sure it's WindowType property is set to 1 (Modal).

Rick

"ShahJagat" <shahjagat (AT) aol (DOT) com> wrote

Quote:
Hi -

I am working on migrating a FPW 2.6 application to VFp. I am very new at VFP.

I am trying to create a form that would return a value that the user inputes
into a text box.

Do form' Myform.scx' to cUserValue

In the form, I have a Text box. 'Text1'.

In the unload event of the form, I have the following two lines of code.

*form unload()
retval=thisform.Tex1.Value
Return retval.

This does not work. When I look at the trace window, it runs into an error at
the line 'retval=thisform.Text1.Value'.
For whatever reason the text1.value is not visible at the form unload event.

What am I dong wrong? I am ready to tear my hair out.

Shah

Reply With Quote
  #3  
Old   
ShahJagat
 
Posts: n/a

Default Re: VFP 7.0 Help - 09-21-2003 , 03:27 PM



Yes. The window type is set to Modal. Still it does not work. For some reason
the Unload event of the form cannot see the value of the text1 box.

Reply With Quote
  #4  
Old   
ShahJagat
 
Posts: n/a

Default Re: VFP 7.0 Help - 09-21-2003 , 07:02 PM



I am doing somethign wrong and I cant put my finger on it.

In the valid event of the Text1, I put the code
lretval=thisform.text1.value

I have a command button that has the following code in its click() event
*Command1.Click()
Thisform.unload

In the unload() property of the form, I have
Return lretval

It gives me an error. The lretval was created in the valid event of the Text1.
It is not visible in the forms unload event.

I then added lretval as a form property thinking maybe it is not visible unless
it is added as a new form property. It still does not work.

Reply With Quote
  #5  
Old   
Dan Freeman
 
Posts: n/a

Default Re: VFP 7.0 Help - 09-22-2003 , 01:54 PM



Variables are scoped exactly the same in VFP as they were in FPW. When the
procedure that created the variable ends, the variable is released, unless
it was created public. So when your valid method ends, your variable is
released.

If you need a value available in multiple form methods, create a form
propert. (Form->New Property on the menu.) In your textbox's valid, store
the value to the property. In the unload, RETURN Thisform.YourProperty.

And as an aside, NEVER call form.Unload. Ever. Unload is an event method
which is called automatically when a form releases. Calling it yourself may
interfere with normal event processing. Use Thisform.Release() instead.

Dan


"ShahJagat" <shahjagat (AT) aol (DOT) com> wrote

Quote:
I am doing somethign wrong and I cant put my finger on it.

In the valid event of the Text1, I put the code
lretval=thisform.text1.value

I have a command button that has the following code in its click() event
*Command1.Click()
Thisform.unload

In the unload() property of the form, I have
Return lretval

It gives me an error. The lretval was created in the valid event of the
Text1.
It is not visible in the forms unload event.

I then added lretval as a form property thinking maybe it is not visible
unless
it is added as a new form property. It still does not work.



Reply With Quote
  #6  
Old   
lemmebe@frednwilma.com
 
Posts: n/a

Default Re: VFP 7.0 Help - 09-22-2003 , 05:46 PM



On 22 Sep 2003 00:02:25 GMT, shahjagat (AT) aol (DOT) com (ShahJagat) wrote:

Further to what Dan said about never calling Form Unload, In your Click
event, you can call ThisForm.Release(), or even ThisForm.QueryUnload() if
you want to check some things out before allowing the form to unload. If you
return .F. from QueryUnload, the form will not unload.

As Dan said, Unload will be called automatically when the form is destroyed
in the sequence in which it was meant to be called.

Alan

Quote:
I am doing somethign wrong and I cant put my finger on it.

In the valid event of the Text1, I put the code
lretval=thisform.text1.value

I have a command button that has the following code in its click() event
*Command1.Click()
Thisform.unload

In the unload() property of the form, I have
Return lretval

It gives me an error. The lretval was created in the valid event of the Text1.
It is not visible in the forms unload event.

I then added lretval as a form property thinking maybe it is not visible unless
it is added as a new form property. It still does not work.
My real address is alan at sprint dot ca
(with a 'p' on 'alan' making it 'alanp',
and no spaces). I'm sick of email spam.


Reply With Quote
  #7  
Old   
ShahJagat
 
Posts: n/a

Default Re: VFP 7.0 Help - 09-22-2003 , 09:55 PM



Hi Alan & Stefan -

Thanks for your input.

But I am still facing a problem.

The system works and returns the value correctly if I return 'Thisform.lretval'
from the unload() property of the form.

The text box for the user input is bound to the Thisform.lretavl as
controlsource property.

As you guys suggested, I tried calling thisform.release() from the valid event
of the command button and in the form release method I have 'Return
Thisform.lretval'

But it does not return a correct value that was input by the user, it returns a
..T.

Any ideas ??? The same code works like a chrm if it is in the Form unload()
event. But if I put in into the form releaseevent it returns a .T.

Reply With Quote
  #8  
Old   
Stefan Wuebbe
 
Posts: n/a

Default Re: VFP 7.0 Help - 09-23-2003 , 02:08 AM



Hi,

Quote:
The system works and returns the value correctly if I return
'Thisform.lretval'
from the unload() property of the form.
Yes, form.Unload() is the right place to return a value from a
modal form.

But in your commandbutton.Click() you want to call the .Release
method of your form.
Dan's point was about the difference between events and methods.
form.Release() is a method, so you can call it and your form will
probably be released. During that process the form events Unload
and Destroy will just happen automatically.

QueryUnload is an event too, but it happens only when you close
a form by clicking the upper-right 'x' close button in the title bar.
Release is not an event, it does not fire automatically when a form
object is destroyed.


hth
-Stefan



Reply With Quote
  #9  
Old   
ShahJagat
 
Posts: n/a

Default Re: VFP 7.0 Help - 09-23-2003 , 11:35 AM



It worked !!!!. Thanks a lot guys. Now I get it. I put the Thisform.release()
in the valid method of the Command Button. And ' Return Thisform.lretval' was
put in the Form unload() event. And everything worked......

The only book I have with me for reference is the 'Building Visual Studio
Applications' on visual Foxpro 6.0 Foundation by Whil Hentzen. And though I
read the corresponding section on passing of parameters and returning values
from a Form, it does not tell me all this that I needed to do to make it work
right. For sure I am going to run into many such situations. Can you all
recommend some good book that I probably need?

Thanks again... Your input has helped me a lot....

Shah

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.