Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

Passthrough function with TField as parameter?

edited February 2012 in RAP
Hello,

is it possible to make / use a passthrough function with TField as
parameter?

I'm trying to make one, but it fails to compile when I try to ope the
"language"-tab. Once I change the parameter from TField to string or
something like that, it works.

What I want to do, is: pass a .FieldObjects['FieldAlias'] to a
function I have in Delphi, which checks if a field is a TBlobField and
returns some plaintext out of it's content.

How can I get this to work?

Regards,
Mark

Comments

  • edited February 2012
    Hi Mark,

    Try passing the TField as a TObject and then typecast it in the pass
    thru function. Otherwise, you can always pass the entire pipeline
    object to the passthru function then manipulate it in Delphi as you need.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2012
    Hi Nico,

    TObject works and also TppField, which I tried inbetween, but in both cases
    the typecasted field isn't being recognized as TBlobField. Even if I
    typecast my TObject-parameter or my TppField-parameter straight as
    TBlobField.

    Isn't a field returned by Pipeline.FieldObjects a blobfield? Then it
    probably wouldn't work either, if I would pass the entire pipeline as
    parameter.

    Maybe you have another idea. I need a possibility to save the content of the
    said field (RichView-format) to a stream and then to get the plaintext out
    of it with my delphi function.


  • edited February 2012
    My mistake, FieldObjects only returns TppFields which are not Delphi
    TFields. (See ppDB.pas).

    By passing the pipeine, you could access the underlying TDataset and
    access the TFields from there.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2012
    Hi Nico,

    trying to accomplish it with the pipeline as parameter now.
    if it's the pipeline within the DetailBand, will the dataset have the
    correct record located each time automatically?

    Other than that:
    I seem to have a problem, that the pass through function is being called
    twice and the second call end with a AV because the second time the pipeline
    seems to be corrupted (some weird symbols when I move the cursor over it
    during debugging). The error occurs in TppDBPipeline.GetDataSource

    I'm calling the pass through function like this:
    ... := myPassThroughFunction(PipelineName, 'FieldAlias');


    Any ideas?

  • edited February 2012
    A small addition:
    I'm calling the function in OnCalc of a variable. It's being fired twice.
    Do I have to check for the first / second pass here? Not doing it in any
    calculations in general, if I remember correct...


  • edited February 2012
    Another note:
    the AV in the second call was caused by me returning the result not in the
    last item of the TraParamList.
    Since I have two parameters (items 0 and 1 in the param list), it should be
    "SetParamValue(2, myResult);" and not "SetParamValue(1, loc_Result);" as I
    was doing first.

    But the OnCalc-event of the variable and so my pass through function is
    still being called twice. Since I'm accessing the DataSet, saving a field to
    stream and doing some more stuff there, two calls could cause a delay.

    Not sure if that's correct...


  • edited February 2012
    In my testing with a simple application, the OnCalc event of a
    TppVariable fires only once per traversed record.

    1. Be sure the type of the Variable is set to a numeric type rather than
    String if you wish to make calculations.

    2. If you are using a two pass report, you will need to check for this
    as the event will fire once for each pass.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2012
    > 1. Be sure the type of the Variable is set to a numeric type rather than
    That's an important hint. All my variables with calculations are of the type
    string as that's the default type when a variable is created.
    Changing the type to integer has the effect, that OnCalc is fired only once,
    but the calculations seem not to work properly in that case. I have some,
    where the visibillity of some components is being changed depending on
    conditions and some components seem to remain visible, although the should
    be invisible. Changing the type back to string -> everything is ok again.

    Once I change the type to integer, the event is already called only once,
    although I'm working with two pass reports. You are saying that it should be
    called twice, so something seems to be wrong here...

    Assumed it would fire once per pass: in which one should the calculation
    happen?

    Kind regards,
    Mark


  • edited February 2012
    My bad regarding point 1, sorry :(
    All my variables with calculations were visible. With string as type their
    value was empty, it seems, so they were really not visible on the report.
    If the variable is of the type integer, it has 0 as value and so the 0 was
    visible then and it was accidentaly exatly on the place where I'm hidding /
    showing some of the components. Once I set variables to visible := false,
    it's all good. Sorry.

    Point 2 is still "open" though.


  • edited February 2012
    Place a variable on a two pass report set to calculate on Traversal.
    Add a ShowMessage command to the OnCalc event of the variable. The
    message will display twice for each record (once during the first pass,
    once during the second).

    This is working as designed.

    The first pass is mainly for values that cannot be obtained unless the
    report is pre-generated (i.e. PageCount).

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.