Function in MemoView and OnGetValue problem
Hi,
I'm not sure if there is some simple option for this or if this is a bug:
Imagine you have a Memoview that contains this:
[IIF([Dataset.Field1]>0, 'hello', 'bye')]
This works in a simple report.
But if you use the OnGetValue Event then the IIF is sent there instead of being processed by the report.
This makes using functions in MemoViews useless because I'd have to write a parser to process them myself.
Is this intended or a bug?
Best regards
Bob.
I'm not sure if there is some simple option for this or if this is a bug:
Imagine you have a Memoview that contains this:
[IIF([Dataset.Field1]>0, 'hello', 'bye')]
This works in a simple report.
But if you use the OnGetValue Event then the IIF is sent there instead of being processed by the report.
This makes using functions in MemoViews useless because I'd have to write a parser to process them myself.
Is this intended or a bug?
Best regards
Bob.
Comments
As you observe, whole expressions seem to come through OnGetValue recursively, in progressively smaller chunks, until Value is changed by your handler or the expression is resolved by the internal code as it goes around.
Something along the lines of
if VarName = 'MyField1' then
Value := Mydata[Dataset.RecNo].Field1
else if VarName = 'MyField2' then
Value := Mydata[Dataset.RecNo].Field2;
with something like a list lookup if you are supporting multiple columns or different query results.
Having a trailing "else Value := 'Error'" in the code above guarantees failure!!
I'm using it for SQLite query results via a lightweight shim and internally generated tables/lists.
Good thing you answered. This made me check my OnGetValue Code again. And it turns out that I change the value of the "Value" variable to "Null" if it isn't set.
If I do that then the expression in VarName isn't resolved by the internal code.
You'd think they'd include that in their documentation.
Thank you very much.
Edit:
For other people also getting this problem: If you want to reset the "Value" parameter so the content of "VarName" is resolved internally then set it to "Unassigned":