Passthrough function with TField as parameter?
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
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
This discussion has been closed.
Comments
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.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
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.
TFields. (See ppDB.pas).
By passing the pipeine, you could access the underlying TDataset and
access the TFields from there.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
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?
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...
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...
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.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
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
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.
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).
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com