Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Border Color
Message
From
03/10/2018 15:11:44
 
 
To
03/10/2018 11:49:49
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Database:
MS SQL Server
Miscellaneous
Thread ID:
01662372
Message ID:
01662466
Views:
39
The longterm watershed for maintainance is the # objects getting the same value(s) vs. # of properties to store someting into...
If the # of proprties to set skyrockets, your code will issue less single usercode fucntion calls, as those are slow compared to vfp runtime function calls.
Another point in favor of getting object handle and calling a function on/with it is that building an iterator pattern will be more flexible, while generalizing from "my" approach would probably always be more discrete by looping over an array of tcPropertyName and tuValue settings, as a cursor would probably need a type hint to cast to...

Anyway, the cat in your example can be skinned thataway ;-)
	PROCEDURE PaintLinesAlternative()
            setLineGroupProp("bordercolor", guisettings.gridbordercolor)
            setLineGroupProp("borderstyle", guisettings.gridborderLineStyle)
            setLineGroupProp("borderWidth", guisettings.gridborderLineWidth)


	PROCEDURE setLineGroupProp(tcPropName, tuValue)
		LOCAL oParent, lcPre, lcPost
		oParent = THIS.parent
	        lcPre = "m.oParent." + this.NAME + "_"
	        lcPost = "." + m.tcPropName
                
		 TRY
			Store m.tuValue To;
			    (m.lcPre + "T" + m.lcPost), ;
			    (m.lcPre + "L" + m.lcPost), ;
			    (m.lcPre + "R" + m.lcPost), ;
			    (m.lcPre + "B" + m.lcPost), ;
			    (m.lcPre + "H" + m.lcPost)
		ENDTRY
		RETURN
	ENDPROC
>Your approach has the advantage of getting an object reference, which you may need if you wanted to do more things to it. At this point, with just color, Thomass's wins the elegance contest (and it's a one-liner!). If you wanted to change, say, line pattern or some such property, then it would be easier with object reference.
>
>
	PROCEDURE PaintLines()
>		LOCAL oLine, oObject 
>
>		oObject = THIS
>		TRY
>			oLine = GETPEM(oObject.PARENT, oObject.NAME+"_T")
>			this.PaintLine(oLine)
>			oLine = GETPEM(oObject.PARENT, oObject.NAME+"_L")
>			this.PaintLine(oLine)
>			oLine = GETPEM(oObject.PARENT, oObject.NAME+"_R")
>			this.PaintLine(oLine)
>			oLine = GETPEM(oObject.PARENT, oObject.NAME+"_B")
>			this.PaintLine(oLine)
>			oLine = GETPEM(oObject.PARENT, oObject.NAME+"_H")
>			this.PaintLine(oLine)
>		ENDTRY
>
>	PROCEDURE PaintLine(toLine)
>		with toLine
>			.bordercolor=guisettings.gridbordercolor
>			.borderstyle=guisettings.gridborderLineStyle
>			.borderWidth=guisettings.gridborderLineWidth
>		endwith
>
Previous
Reply
Map
View

Click here to load this message in the networking platform