Extracting data from a memo field.
In a DB memo field we keep data which may vary from record to record
but it's structure is the same. For example:
EmployeeID=12
Amount=30.00
SpotDate=12/11/2002
etc..
Even though the field names in the memo fied (i.e. EmployeeID) and the
values (i.e 12) may vary from record to record. The layout is the same
=. I would like to have some kind of function that I can
use in the end user report builder to extract value from a field as a
string. Somthing like this:
Function Extract(Const Field: String): String;
I could then make a call like this..
S := GetData('EmployeeID');
..and it would return '12'. If the field did not exists it would just
return an empty string.
If I was doing this in Delphi it would be easy I would just put the
contents into a tStringList and use ValueOf.
How can I do somthing like this using the End User report builder?
I am Using Report Builder 7.03 Enterprise Edition, Delphi 6, and DBISAM
V 3.27.
Thanks,
J. Michael Eubanks
Ideal Software Systems, Inc.
but it's structure is the same. For example:
EmployeeID=12
Amount=30.00
SpotDate=12/11/2002
etc..
Even though the field names in the memo fied (i.e. EmployeeID) and the
values (i.e 12) may vary from record to record. The layout is the same
=. I would like to have some kind of function that I can
use in the end user report builder to extract value from a field as a
string. Somthing like this:
Function Extract(Const Field: String): String;
I could then make a call like this..
S := GetData('EmployeeID');
..and it would return '12'. If the field did not exists it would just
return an empty string.
If I was doing this in Delphi it would be easy I would just put the
contents into a tStringList and use ValueOf.
How can I do somthing like this using the End User report builder?
I am Using Report Builder 7.03 Enterprise Edition, Delphi 6, and DBISAM
V 3.27.
Thanks,
J. Michael Eubanks
Ideal Software Systems, Inc.
This discussion has been closed.
Comments
You can very easily extend RAP (i.e. the Calc workspace) to include custom
functions such as the one you describe. These custom functions will show up
in the CodeToolbox. See article below:
--------------------------------------------------
Article: Extending RAP
---------------------------------------------------
There are two very simple and powerful techniques to extend the capabilities
of RAP infinitely. These are summarized below and covered in more detail in
the RAP.hlp online help. Demos and tutorials are installed to
RBuilder\Demos\RAP. The tutorial text is located in RAP.hlp.
1. RAP Pass-Through Functions
These are functions that appear in the Language tab of RAP's Code Toolbox.
These functions are written in Delphi and can be called from RAP. RAP's
pass-through function architecture enable's developers to add new built-in
functions to RAP's code toolbox.
2. Extend RAP's RTTI
RAP's Run-time Type information defines what classes and properties can be
accessed via RAP. By default the published properties of any class that is
registered with Delphi's RegisterClass procedure is recognized by RAP. In
addition many of the public properties and methods of ReportBuilder classes
are exposed.
--
Tech Support mailto:support@digital-metaphors.com
Digital Metaphors http://www.digital-metaphors.com
-
Nard Moseley
Digital Metaphors
http://www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Nard,
Thank you, it works great.
BTW here is the code final code:
unit RAPCustom;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, raFunc, ppRTTI;
type
TGetStrValue = class (TraStringFunction)
public
procedure ExecuteFunction(aParams: TraParamList); override;
class function GetSignature: String; override;
end;
implementation
class function TGetStrValue.GetSignature: String;
begin
Result := 'function GetValue(const Contents, FieldName: string):
string;';
end; {class function, GetSignature}
procedure TGetStrValue.ExecuteFunction(aParams: TraParamList);
var
lsResult: String;
StrList: tStringList;
lsString: String;
begin
GetParamValue(0, lsString);
StrList := TStringList.Create;
StrList.Text := lsString;
GetParamValue(1, lsString);
lsResult := StrList.Values[lsString];
StrList.Free;
SetParamValue(2, lsResult);
end; {procedure, ExecuteFunction}
initialization
raRegisterFunction('GetValue', TGetStrValue);
finalization
raUnRegisterFunction('GetValue');
end.
Thanks again,
J. Michael Eubanks
RAP functions are very cool!
--
Nard Moseley
Digital Metaphors
http://www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com