Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
#DEFINE idiosyncracy
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00559473
Message ID:
00559938
Views:
14
Sergey,

Most curious... on your request, I went back and redid the test form using VFP base classes. I didn't think there'd be any difference as my company's base classes are straight copies of the VFP base classes.

When I ran the form with a #DEFINE that had a real message, the #DEFINEs worked as advertised. When I ran the form with a very short #DEFINE message, the #DEFINE in the Init was displayed.

I ran the Class Browser and copied the code into a .prg (included below) and the form ran correctly every time.

I'm not sure why it would run differently in a prg vs an scx. Maybe because of the way the p-code compiler handles scx?

Regards,
Thom C.
* PROGRAM: DefTest.prg
LOCAL loForm

loForm = CREATEOBJECT("Form1")

loForm.Show(1)

RETURN


DEFINE CLASS form1 AS form
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 180, ;
		Left = 192, ;
		Height = 37, ;
		Width = 133, ;
		Caption = "Command1", ;
		Name = "Command1"

	PROCEDURE command1.Click
		#DEFINE dcEcho "dcEcho is defined in Click() event"
*!*			#DEFINE dcEcho "."

		WAIT WINDOW dcEcho
	ENDPROC

	PROCEDURE command1.Init
		#DEFINE dcEcho "Test of dcEcho... define is in Init()"
	ENDPROC

ENDDEFINE
***************************************

Vlad,

>>ALL #DEFINE directives are stored in the memory during the compilation process, they're always public to ALL modules (there is also #UNDEFINE directive that can make it local to some code snippet by defining constant than un-defining it again).

Generally, I agree with your statements. But I have to take issue with the #DEFINEs being PUBLIC... MS says they are not when applied to a method/event in a VCX/SCX... that's why I got into this little experiment in the first place. I expected the #DEFINE in the Init() to "die" at the end of the method.
I absolutely did not expect the arbitrary results I've been getting. Oh, well, just one more VFP idiosyncracy to look out for.

Regards,
Thom C.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform