Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Local scoop wish
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00720623
Message ID:
00721037
Views:
12
I don't agree with this new SYS () function as it would support not declaring all variables used by a given function which is a bad programming practice IMHO. You can use _VFP.LanguageOptions to force the declarations of variables.
Define Class Test As Session

	Protected Function Init()
		_VFP.LanguageOptions = 1
	EndFunc

	Function Test1
		x = 1   && Error
		? x
		? This.Test2()
	EndFunc

	Function Test2
		Return x && Error
	EndFunc
	
EndDefine
Define Class Test As Session

	Protected Function Init()
		_VFP.LanguageOptions = 1
	EndFunc

	Function Test1
                LOCAL x
		x = 1   && OK
		? x
		? This.Test2()
	EndFunc

	Function Test2
		Return x && Error
	EndFunc
	
EndDefine
>I don't beleive you got me right, my wish was to have a new sys() function to changed the default behavior of VFP from creating all undeclared variable as LOCAL to the function declaring it:
>
>Current behavior:
>ox = CreateObject("Test")
>=ox.Test1()
>
>Define Class Test As Session
>
>	Function Test1
>		x = 1
>		? x
>		? This.Test2()
>	EndFunc
>
>	Function Test2
>		Return x && x is private so no error here
>	EndFunc
>	
>EndDefine
>
>
>New Sys() Option
>
>
>ox = CreateObject("Test")
>=ox.Test1()
>
>Define Class Test As Session
>	
>	Protected Function Init()
>		=Sys(9999, 1)  && New sys function
>	EndFunc
>	
>	Function Test1
>		x = 1
>		? x
>		? This.Test2()
>	EndFunc
>
>	Function Test2
>		Return x && x an error here, x is local to test1()
>	EndFunc
>	
>
>EndDefine
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform