Re: VFP Objects for a beginner - help!
- From: "Dan Freeman" <spam@xxxxxxxxxxxxx>
- Date: Thu, 4 May 2006 12:10:06 -0700
These are deceptively HUGE and complex questions. LOL
An "object" (which really only exists at runtime) is nothing but a blob that
contains some data and some code. It may or may not do something useful.
Using your "Hello World" as an example, you'd start with a class definition
that might look like this:
Define Class myTextFileMaker As Session
textmessage = ""
Procedure SetMessage(somestring)
this.textmessage = somestring
Endproc
Procedure WriteFile(filename)
StrToFile(this.textmessage,filename)
Endproc
Enddefine
You'd call that this way:
ox = CreateObject("MyTextFileMaker")
ox.SetMessage("Hello World")
ox.WriteFile("c:\hello.txt")
ox.Release()
IOW, OOP is nothing but new packaging on well-organized code. There are
general concepts, though. You'll notice "As Session" in the class definition
above. That means that myTextFileMaker will *inherit* all of the properties
and behaviors of VFP's Session class, including the Release() method that I
called.
To go much deeper into this would be unproductive in a newsgroup post, but
fortunately there are LOTS of books available to you. Go to
www.hentzenwerke.com and have a look around. "Fundamentals" would probably
be good since it presumes fore-knowledge of previous versions of Fox. If you
can find a copy, look for Savannah Brentnall's "Object Oriented Programming
in Visual Foxpro" (not a Hentzenwerke title, unfortunately).
And come back here when you have specific questions!
Dan
JWB wrote:
I'm an self-taught old-school programmer who uses VFP 6 and,
embarassingly, never got in to exploiting the power of objects.
Although very fast and optimized, all my code constists of function
calls, passing and returning paramters, etc. I want to begin porting
some of these paramterized functions in to objects that I can use
from within this app but also distribute so that another guy who is a
VB .net programmer can drop in his app. Hope I'm stating this
correctly so far.
So my question is, how do I get started? I read the help stuff and
it's foreign to me as I try and relate it to a paramterized function.
If I wanted to create an object in VFP that did some lowly task just
for the sake of doing it, for example...writing a text file that
contains the text "Hello World", how would Io that?
- Ben
.
- Follow-Ups:
- Re: VFP Objects for a beginner - help!
- From: Cindy Winegarden
- Re: VFP Objects for a beginner - help!
- From: JWB
- Re: VFP Objects for a beginner - help!
- References:
- VFP Objects for a beginner - help!
- From: JWB
- VFP Objects for a beginner - help!
- Prev by Date: Re: VFP 6 - problem with RUN command
- Next by Date: Adjusting the grid control?
- Previous by thread: VFP Objects for a beginner - help!
- Next by thread: Re: VFP Objects for a beginner - help!
- Index(es):
Relevant Pages
|
Loading