Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: ursula
  Where is ursula?
 Jakarta
 Indonesia
 ursula
 Tags
Subject: RE: DynamicBackColor >255
Thread ID: 289028 Message ID: 289110 # Views: 39 # Ratings: 2
Version: Visual FoxPro 9 SP2 Category: Grids
Date: Tuesday, December 28, 2010 12:11:13 PM         
   


> Hi all,
>
> I got an error saying "unrecoqnized command verb" when I use this syntax below. I notice that actually because the syntax is more than 255 char. Please advise how should I do.
>
>
Thisform.grdlcsrch.SetAll("DynamicBackColor", ;
>     "IIF(TRIM(tmpLpsd.notes)='YELLOW',RGB(247,247,171),IIF(TRIM(tmpLpsd.notes)='BLUE',RGB(214,216,250),IIF(TRIM(tmpLpsd.notes)='GREEN',;
>     RGB(214,250,214),IIF(TRIM(tmpLpsd.notes)='RED',RGB(255,224,193),IIF(TRIM(tmpLpsd.notes)='BROWN',RGB(207,159,111),THIS.Column1.BackColor)))))", "Column")

>
> Thanks
> Ursula

Since this is not solely related to setting dynamicbackcolor but with 255 literal string limit in general here are multiple ways to solve:

Solution 1: Divide the one literal string into multiple ones

Thisform.grdlcsrch.SetAll("DynamicBackColor", ;
	"IIF(TRIM(tmpLpsd.notes)='YELLOW',RGB(247,247,171),"+;
	"IIF(TRIM(tmpLpsd.notes)='BLUE',RGB(214,216,250),"+;
	"IIF(TRIM(tmpLpsd.notes)='GREEN',RGB(214,250,214),"+;
	"IIF(TRIM(tmpLpsd.notes)='RED',RGB(255,224,193),"+;
	"IIF(TRIM(tmpLpsd.notes)='BROWN',RGB(207,159,111),THIS.Column1.BackColor)))))")


Note that specifying "Column" in SetAll() is redundant. Only column have DynamicBackColor property and it is unnecessary UNLESS you meant to apply it to base class column objects when there are also custom class based ones like 'MyColumn'.

Solution 2: Again divide into multiple literals and also replace iif() series with inline do case aka iCase:

Thisform.grdlcsrch.SetAll("DynamicBackColor", ;
	"ICase(TRIM(tmpLpsd.notes)='YELLOW',RGB(247,247,171),"+;
	"TRIM(tmpLpsd.notes)='BLUE',RGB(214,216,250),"+;
	"TRIM(tmpLpsd.notes)='GREEN',RGB(214,250,214),"+;
	"TRIM(tmpLpsd.notes)='RED',RGB(255,224,193),"+;
	"TRIM(tmpLpsd.notes)='BROWN',RGB(207,159,111),THIS.Column1.BackColor)")


Solution 3: Use text ... endtext to wrap long strings
TEXT TO lcExpression noshow
ICase( ... )
ENDTEXT
Thisform.grdlcsrch.SetAll("DynamicBackColor", m.lcExpression)


Solution 4: Delegate the code to a custom form method. This is the preferred method when the expression is long and complex. Property is set to a function call and the function handles the complexity of operation and returns a simple value:

Thisform.grdlcsrch.SetAll("DynamicBackColor", "(thisform.MyColor(THIS.Column1.BackColor))")

*MyColor custom form method
Lparameters tnDefault
Local lcValue
lcValue = Trim(tmpLpsd.notes)
Do Case
	Case m.lcValue='YELLOW'
		Return Rgb(247,247,171)
	Case m.lcValue='BLUE'
		Return Rgb(214,216,250)
	Case m.lcValue='GREEN'
		Return Rgb(214,250,214)
	Case m.lcValue='RED'
		Return Rgb(255,224,193)
	Case m.lcValue='BROWN'
		Return Rgb(207,159,111)
	Otherwise
		Return m.tnDefault
endcase


PS: I didn't understand the purpose of trim() without == but kept it anyway.

Cetin Basoz

.Net has got better.Think about moving - check my blog:
Blog (main)
Blog (mirror)

ENTIRE THREAD

DynamicBackColor >255 Posted by ursula @ 12/28/2010 3:38:08 AM
RE: DynamicBackColor >255 Posted by Samir H. @ 12/28/2010 3:49:01 AM
RE: DynamicBackColor >255 Posted by Jun Tangunan @ 12/28/2010 4:38:12 AM
RE: DynamicBackColor >255 Posted by Samir H. @ 12/28/2010 5:05:37 AM
RE: DynamicBackColor >255 Posted by Jun Tangunan @ 12/28/2010 5:20:49 AM
RE: DynamicBackColor >255 Posted by ursula @ 12/28/2010 5:10:02 AM
RE: DynamicBackColor >255 Posted by Cetin Basoz @ 12/28/2010 12:11:13 PM