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

Creating an instance of a class in VFP 6 1

Status
Not open for further replies.

DSaba10

Programmer
Nov 15, 2007
35
US
So I'm attempting to create a class to use, but I want to create it straight in code rather than using the VFP Visual tools in VFP 6. I am not making a visual application. Is there a way to do this? I've attempted to create my class inside a prg, and to start I went with Ye Olde "Hello, World!" class

Code:
define class MyClass AS Custom

	function MyFunction()
		
		? 'Hello, World!'
		
	endfunc

enddef

Will this work if written in a .prg file? How can I create an instance of this class within another prg, or should I be creating this as a .h file in C and #including it to use, and if so, I still am unsure of how to create the instance of the class.

Thanks!
 
SET PROCEDURE TO your.prg ADDITIVE
loObject = Createobject("MyClass")

Or...

loObject = NewObject("Myclass","my.prg" [,the.exe])
 
Thanks Dan! That indeed worked. That is going to be a tremendous help. It also helps to make sure I have my .prg with the defined class closed when attempting to run another file that uses it :) Custom classes here I come.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top