Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OOP aware DoForm function suggestions
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP1
Application:
Desktop
Miscellaneous
Thread ID:
01370806
Message ID:
01370831
Views:
27
This message has been marked as the solution to the initial question of the thread.
>Hi Cetin
>
>>What do you mean "OOP wants me to populate the properties instead of passing parameters and I agree with it"? I wouldn't agree, I think but probably I didn't understand.
>
>Yes, you have guessed right. As for OOP I am under the impression that the LPARAMETERS in the init() of a class is something that should be avoided and instead properties are used which are populated in code to replace LPARAMETERS
>
>>oForm = doform()
>>oForm.SomeProperty = somevalue
>
>DoForm() does not do much
>
...
>			loObject = CREATEOBJECT(tcClassName, @tuParm1, @tuParm2, @tuParm3, @tuParm4)
>	ENDCASE
>
>	IF TYPE("loObject.Name") == "C"
>*  ===>  this is where the properties should be populated if I avoid the above call parameters
>		loObject.SHOW()
>
>		IF TYPE("loObject.uRetVal") # "U"
>			RETURN loObject.uRetVal
>		ENDIF
>
>	ENDIF
>...
>
>Probably this was a wrong question and I just got carried away with it. As I will have to manually call .SHOW() in case even if I do something as what you have hinted.
>
>Thanks.

I can think of two alternitives up front.

1) Change the LPARAMETER to a PARAMETER. The LPARA... are local variable where the PARA... are Private variable. The .Show method should then be able to see them. You could then set the form's properties from them. This relates the setting of the properties up to the various forms being opened.

2) Preset a Collection object with the Key being the Property's Name and the Value to the value those properties are to be changed. Pass the collection to the DoShow as the only parameter. Then before the .Show in the DoForm read the collection passed; drawing the property name from the Key and setting the Form object property the value in the Value part of the collection. This method differs from the first in that the calling section to DoForm controls which properties are set and what they are set to.
LOCAL x as Integer
FOR x = 1 TO tuPara1.Count
      IF TYPE( "loObject."+tuPara1.GetKey( x ) ) $ "CNDTL"
           STORE tuPara1.Item( x ) TO ("loObject."+tuPara1.GetKey( x ) )
      ENDIF
NEXT
*
loObject.Show()
Or something like that...
Greg Reichert
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform