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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing class properties internally 1

Status
Not open for further replies.

DEDMOD

Programmer
Feb 1, 2001
721
US
I'm trying to create some classes and I'm not sure how to reference user defined properties of the class from within objects in the class. Thus I'm trying to manipulate the "schema" property of the class from within the click event of a command button.

I tried this.schema without much hope, and indeed it told me it couldn't find a 'schema' property. Likewise with "sentence.schema" where "sentence" is the class name. So what do I do? Or at least, what should I read to figure it out?

Dave Dardinger
 
Hi,
The properties you create can be used and modified by you from within the form while at runtime. If the property created is at form level.. then.. you shall reference it as
ThisForm.schema. If the property is defined as part of another object... then reference shall be done as...
ThisForm.myObject.schema

CAUTION..... In VFP... schema is defined as..
"A definition of the total database layout, including integrity checks and persistent relationships among tables and their indexes.".
Because of this.. (I am no 100% sure.. since I havent tried it..)... if the word schema is a protected word.

Another thing you have to keep in mind , is that, when the properties are created at form level, the default value given by the system is .F. I would suggest to initialise it with a space and then a back space .. to indicate it is Character type value and initialised with 'none' (i.e. empty). Also you can initialise it with 0 (Zero) or blank date format as you may want it to be.

Hope this helps.
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Just a littlemore thinking...
I suggest always use your variables.. properties..commands etc.. signify you with their meaning plus an intial notation to indicate what it is by value type...

Example.. cSentence .. my sentence (c for character)
nInvTotal .. my invoice total (n for numeric)
lChoice ... my choice Yes or No... l for logical

You can even add in front .. l for local.. p for pulic etc.. so makint the above as
lcSentence.. pnInvTotal... llChoice ... etc.
The advantages are that you exactly know what you are doing with the variable or property created, then at what level you are initialising it.. and then it helps to avoid protected words.. (may be sentence is protected word.. but cSentence is not)

Hope the idea helps. ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
I'm not sure if I've made myself perfectly clear. What I have is a class I made starting with a container object and adding a text box, an edit box and a commandgroup.

When I add a property to the class it appears in the property list of the container object. I don't think there's a problem addressing the property at run-time from outside the object (that is, from another object on the form. But I want to change the value of the property from the click event one of the command buttons of the command group, and I don't know exactly how to reference it. I don't have a form inside the class or available at the class designer, so it doesn't seem likely that I'd address it as "thisform.sentence.schema", although I suppose I should try just in case. But I don't see exactly how I do do it.

By the way, it's a good point that 'schema' may be a reserved word, so I'll try changing it.

I hope this makes my quandry clearer. Thanks for the help so far.

Dave Dardinger
 
Ohhhhhhhhhhh
Let us say..
MyContainer1...
in that... textBox1, editbox1, comdButton1 etc.
Now referencing the ...
textbox1 from the cmdButton1.Click event
This.Parent.TextBox1.whatever property.

So This.Parent..... is the Key. This is the safe way.. because, you can instatiate the class with different names.Always.. This.Parent.TextBox1 is valid from the cmdButton1.

Hope this helps you :)
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Yes! .parent is what I need. (At least I assume it is. I'll have to go test.) I think it almost came to mind but then I let it slip away. I knew there were parent classes and I guess I assumed .parent wouldn't be used for container-object relationships. But I shouldn't have made that assumption since I know about parent-child forms.

I do wish the help files were a bit better when it comes to spelling out such obvious questions.

Anyway, thanks a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top