Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to find out if parameter was passed by ref
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00648668
Message ID:
00648682
Views:
22
Hi Gérald,

>In the documentation of the method <g> :-)
<vbg>

>Seriously, I dont know, but what kind of method will wait for any type of parameters?
>Can you explain a bit more what you are trying to do?

Sure! I want to make a method safe to use for any caller. You may already know the following:

loControl.Move(100, 100, 100, 100)
-----------------------------------
Change nLeft to 50 inside Move() -> the control is being moved to position 100.

loControl.Move(@lnLeft, 100, 100, 100)
-----------------------------------
Change nLeft to 50 inside Move() -> the control is being moved to position 50.

Nice behaviour, isn't it? Since I don't want to force any other programmer (including myself <g>) to pass variables by ref instead of passing constants or variables by value, I'm doing the following (code from a strategy object, not from the control itself). IMO not doing this would often lead to confusion and errors. Now I thought of making this a little faster by only calling move a second time, if the parameters where passed by value.
LPARAMETERS tloObject, nLeft, nTop, nWidth, nHeight

LOCAL lnLeft, lnTop, lnWidth, lnHeight

WITH tloObject
	IF NOT .lMoveInProgress
	
		lnLeft	 = THIS.GetLeft(tloObject, nLeft, .T.)
		lnTop	 = THIS.GetTop(tloObject, nTop, .T.)
		lnWidth	 = THIS.GetWidth(tloObject, nWidth, .T.)
		lnHeight = THIS.GetHeight(tloObject, nHeight, .T.)
		
		.lMoveInProgress = .T.
		
		.Move(@lnLeft, @lnTop, @lnWidth, @lnHeight)
		THIS.lDoDefault = .F.
		
	ELSE
	
		.lMoveInProgress = .F.
		THIS.lDoDefault = .T.
		
	ENDIF
ENDWITH 
Armin

Armin Neudert
Regional Director (Stuttgart) of German FoxPro User Group dFPUG

MCP for Visual FoxPro

Expert/Editor of the VFP section in the German Codezone community portal
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform