Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using Evaluate within describe in datawindow expression

1,394 views
Skip to first unread message

Gord Harris

unread,
Feb 2, 1999, 3:00:00 AM2/2/99
to
I am building a datawindow expression to set the background color of a
column based on various property settings of the datawindow and column.
Purpose is to enforce color standards. This expression is being built from
a script executed by the constructor event of a datawindow control, and
placed into the background.color property for the column. One of the
properties I need to check is the PROTECT property, which may or may not
contain an expression. I'm having trouble coming up with a way of handling
the case where there is an expression in this column, specifically regarding
the case where PROTECT may be on or off depending on the row.
I have been trying to use the EVALUATE function to resolve the column's
protect status, which accepts a rownumber. However I need that rownumber to
be dynamic, as I'm building this expression in the constructor event and
need to evaluate row by row. I thought I could use the GetRow() datawindow
function within the Evaluate function, but it appears that the evaluate
function will not accept the getrow() function, as it returns "!" when I
attempt this.

The constructor event calls function containing following code (well this is
part of it only!):

// Determine if Protect property contains an expression
ls_Protect = This.Describe(l_object + ".Protect")
ls_Protect = Right(ls_protect, Len(ls_protect) - Pos(ls_protect, "~t"))

// If so, extract the expression. Either the default value or the
expression will be
// placed in ls_Protect string variable.
If Not IsNumber(ls_Protect) Then
ls_Protect = Left(ls_protect, Len(ls_protect) - 1)
End If
// Build the Evaluate expression. I CAN'T USE A GETROW() within the
EVALUATE expression.
// I also cannot place a row number in here as I need it to evaluate row
by row.
ls_Protect = "Evaluate(~~~'" + ls_Protect + "~~~', 0)" // <---Here is
where I would like to place a getrow() . I used 0 for now, but this
evaluates all rows I think.

// Build the expression that will be placed in the Background.Color property
(basically a NESTED IF expression.
ls_exp = l_Object + ".Background.Color='" + ls_Color +
'~tIf(Describe("Datawindow.Readonly")="yes" Or ' + &
'Describe("' + l_Object + '.TabSequence")="0" Or ' + &
'Describe("' + l_Object + '.Protect")="1" Or ' + &
'Describe("' + ls_Protect + '")="1" Or ' + &
'(Describe("' + l_Object + '.Edit.Style")="edit" And ' + &
'Describe("' + l_Object + '.Edit.DisplayOnly")="yes"),' +
string(RGB(192,192,192)) + ',if("' + &
string(uof_IsRequired(l_Object)) + '"="true",' +
string(RGB(255,255,202)) + ',' + &
String(RGB(255,255,255)) + "))'"

I'm currently using row 0 just to get something in there, but this does not
evaluate properly for datawindows containing more than 1 row.

Is EVALUATE restricted to a specific row number (ie: 1), or am I just doing
something wrong (or in a bad way)? Can I just use the PROTECT expression as
part of the expression I'm building? Do I need to evaluate it in the first
place, when I might just be able to extract the PROTECT expression and
incorporate in my expression. Eg. if PROTECT expression is:
if(ab_protect="1",1,0)

then I could incorporate into my Nested If as:
OR if(ab_protect="1",1,0)="1" or something to this effect!

Anyways, any thoughts or help would be appreciated.


werner.f...@esn-bochum.de

unread,
Feb 3, 1999, 3:00:00 AM2/3/99
to

Gordon,

Be aware of the fact, that such dynamic expression are meant to work with any
row, and we should stay independent from the actual data in the DW (which we
aren't if we evaluate() expressions at this state)! My idea is like this: if
you find that Describe(l_object+".protect") is an expression like e.g.
'0~tif(protect_bit=1,0,1)', extract the "dynamic part", which is of course
'if(protect_bit=1,0,1)'; now, use this whole clause within your expression
for Background.Color as the condition:

Background.Color='0~tif( if(protect_bit=1,0,1) <> 0, RGB(...), RGB(...))'

(Often dynamic protection is implemented thru a helper column in the detail
band, which holds the "protect bit" for the row)
In simple code: To color a column grey in all rows it's protected in (if the
protect attribute is non-dynamic, all or no rows are protected with respect to
this column; with dynamic protection, the same column may be protected in
one row while it's not in another), you might code kind of the following

ls_protect = This.Describe(l_object+".protect")
li_tab = Pos(ls_protect, "~t"
if li_tab > 0 then
ls_protect = Mid(ls_protect, li_tab+1, Len(ls_protect) - li_tab - 1)
This.Modify(l_object + ".background.color='0~tif(" + ls_protect + &
" = 0, RGB(255,255,255), RGB(192,192,192))'")
elseif Integer(ls_protect) <> 0 then
This.Modify(l_object + ".background.color=RGB(192,192,192)")
else
This.Modify(l_object + ".background.color=RGB(255,255,255)")
end if

HTH, Werner

In article <hBJt2.72$y.33...@news.bctel.net>,

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

0 new messages