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.

Comments

  • LurkingKiwiLurkingKiwi Wellington, New Zealand
    edited 5:00PM
    I'm not sure if it's a bug or a feature, but in my GetValue handlers I have to check the VarName parameter for a field I am going to handle, and only change the Value parameter if there is a match.
    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.
  • edited August 2016
    ... until Value is changed by your handler or the expression is resolved by the internal code as it goes around.

    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":
    Value := Unassigned;
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.