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:
00648698
Views:
27
Armin,

I dont see any diferences between param passed by ref or by val in this case.

Since you know that the param was of type N and do nothing special with it, why do you want to know the way it is passed to your method?

.Move(lnLeft, lnTop, lnWidth, lnHeight)
.Move(@lnLeft, @lnTop, @lnWidth, @lnHeight)

Will do the same thing.
If you have some special code in the Move you can set the left (witdh,height or top) property directly without knowing that if you have to force a new position.

You can add an assign method to any property if you need to control its value...

Or I dont understand your point...


>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
If we exchange an apple, we both get an apple.
But if we exchange an idea, we both get 2 ideas, cool...


Gérald Santerre
Independant programmer - internet or intranet stuff - always looking for contracts big or small :)
http://www.siteintranet.qc.ca
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform