Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add properties in the IDE

Status
Not open for further replies.

academica

Technical User
Feb 21, 2010
28
0
0
CN
Hello and forgive my stupid question. I'm still struggling with the IDE in 9.0 :(

I need to add a property to a form to hold a value, which I'm going to pass as a parameter. (The Help for 'How to: Pass Parameters to a Form' says: 'Create properties on the form to hold the parameters...')

How to add properties to a form within the IDE (not programmatically)?

Thanks.

VFP 9.0 SP2 on XP SP3
 
The short answer is as follows:

1. Open the form in the form designer.

2. Select Form / New Property from the menu.

3. Type a name for the property and optionally a description.

4. Click Add. Do that before you click Close.

5. Repeat steps 3 and 4 to add further properties.

6. Click Close.

However, I think the Help text you quoted is slightly misleading. You don't need to create a property in order to pass a parameter. What the Help text is suggesting is that you create a property in the the form that you are calling; this property will then hold the parameter for use in other methods of that form. That might or might not be what you want.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Just reading back the last para in my previous message, I realise it might not be completely clear.

Basically, if you want to pass a parameter to a form, you do this:

Code:
* In the calling form:

DO FORM SomeForm WITH "Mike"
  && "Mike is the value you are passing

* ----------

* In the Init of SomeForm:

LPARAMETERS tcName

* tcName will now hold "Mike"

* If you want to make "Mike" available to other methods
* of SomeForm:

THISFORM.cNameProp = tcName
  && cNameProp is a custom property of SomeForm

I hope that clarifies it.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Yes, that's very clear, Mike. And thanks for the prompt reply.
Since I only show this parameter in a textbox and not use it any methods, I'll do the following (and hope it's OK).

DO FORM Form2 WITH lcWord
......
(in Form2.Init)
PARAMETERS tcAddWord
THISFORM.NewWord.Value = tcAddWord



VFP 9.0 SP2 on XP SP3
 
One more comment on all this. There's a much better version of the New Property and New Method dialogs available at VFPX.

Tamar
 
Thank you, Tamar for this posting.
I guess I'd better install the PEM Editor, which includes the NewProperty and NewMethod replacement?

But the PEM Editor is already another topic.

VFP 9.0 SP2 on XP SP3
 
Academica,

Yes, your code looks fine. As you have realised, there's no need to store the parameter in a property given that you are using it straight away in the Init.

One minor detail: In general, it's better to use LPARAMETERS rather than PARAMETERS. That way, you ensure that the received parameter is scoped locally within the method that receives it. In this case, it won't make any practical difference, but it's a good habit to get into.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
To be honest, I'm not using the PEM Editor. I am using the replacement New Property/New Method dialogs, and I'd hate to go back to the built-in versions.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top