You can get the result of a field property expression for a given row in the dw_1
datawindow by using the evaluate()
datawindow expression in a Describe()
:
string ls_expression = "t2.text"
string ls_text
ls_text = dw_1.Describe("evaluate(~"" + ls_expression + "~", " + string(row) + ")")
Edit: If you need to reuse dynamically a property into another expression in a DW, it becomes a bit tricky
- as you cannot evaluate a property directly with
eval()
because the property is in the form "constant <tabulation> expression"
(including double quotes),
- you need then to either get the value directly
- or you need to evaluate the right part of the expression with taking care of the quotes (here I add one at the beginning, but corresponding ending quote was already given by the describe).
A multi-line dw expression would be:
if(pos(describe("some_field.protect"),"~t")<1, /*if the prop has no tab*/
describe("some_field.protect"), /*no expression, get it directly*/
describe( /*else eval the right part*/
"evaluate(~""
+mid(describe("some_field.protect"), pos(describe("some_field.protect"),"~t")+1)
+",1)" /* 1=for row 1 */
)
)
Some notes:
- as you can see I call several times the describe of the expression, so it would be clearer to construct several computed fields to get in advance
- the
describe()
and have only one expression to query
- the value of the
pos()
of tabulation character
- i have hardcoded the row 1 in my example (at the end of the
evaluate()
, you will need to use string(getrow())
or some other function to evaluate the property at the correct row (or row 0 for header IIRC)
- beware that if you do not put that expression directly in the dw painter but set it via PBScript, you would have to expand the double quotes
"
or simples simple quotes '
with tilda characters depending on the kind of string used in the code