Re: VFP Objects for a beginner - help!



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


.



Relevant Pages

  • Re: VFP Objects for a beginner - help!
    ... Define Class myTextFileMaker As Session ... some of these paramterized functions in to objects that I can use ... VB .net programmer can drop in his app. ...
    (microsoft.public.fox.programmer.exchange)
  • Windows Error at run-time...
    ... My problem is that I am not used to pointers and my little app ... The windows message reads: ... using pointers:| Maybe something is wrong with my class definition ...
    (comp.lang.cpp)
  • Re: [PHP] clases en sesiones
    ... another server with session.auto_start=On, and I have this problem with the ... Please ensure that the class definition ... session was started in on line 43 ... you might try using a .htaccess to override the default php.ini setting ...
    (php.general)
  • Me again...string constants?
    ... I want to define some registry keys that won't change, ... the class definition, but I'd rather just have them available to any ... I'm using CStrings in this app too, so maybe that'd give me some other ... I've seen reference to LTEXTand stuff...my old C reference ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: [PHP] object persistence within a session
    ... I am new to PHP but have 40 years experience programming. ... My initial effort includes a class definition which needs to persist for the duration of a WWW session. ...
    (php.general)

Loading