String parsing - OnGetMemo Event
You can probably figure out what I am trying to do below in the
following Procedure. Report Builder appears to allow you to code pascal
events but it's like not all the way. For example if I try to define a
variable, i.e. var strZip : string[9]; it won't compile but have to tell it
strZip : string; which works. Also, don't think it will handle the
functions RightStr or LeftStr, errors on these 2 functions. How do you
separate or parse a string so I can separate the Zip stored as 882101234
into 88210-1234? Any idea?
Procedure varCompanyAddressOnGetMemo(Lines: TStrings);
var
strZip : string;
begin
if RightStr(COMPANY['ZIP']) <> '' then
strZip:= LeftStr(COMPANY['ZIP'],5)+'-'+
RightStr(COMPANY['ZIP'],4)
else
strZip:= LeftStr(COMPANY['ZIP'],5);
Lines.Clear;
if COMPANY['ADD1'] <> '' then
Lines.Add(COMPANY['ADD1']);
if COMPANY['ADD2'] <> '' then
Lines.Add(COMPANY['ADD2']);
if COMPANY['ADD3'] <> '' then
Lines.Add(COMPANY['ADD3']);
if COMPANY['CITY'] <> '' then
Lines.Add(COMPANY['CITY'] + ', ' + COMPANY['STATE'] + ' ' + strZip;
end;
Tks,
Don
following Procedure. Report Builder appears to allow you to code pascal
events but it's like not all the way. For example if I try to define a
variable, i.e. var strZip : string[9]; it won't compile but have to tell it
strZip : string; which works. Also, don't think it will handle the
functions RightStr or LeftStr, errors on these 2 functions. How do you
separate or parse a string so I can separate the Zip stored as 882101234
into 88210-1234? Any idea?
Procedure varCompanyAddressOnGetMemo(Lines: TStrings);
var
strZip : string;
begin
if RightStr(COMPANY['ZIP']) <> '' then
strZip:= LeftStr(COMPANY['ZIP'],5)+'-'+
RightStr(COMPANY['ZIP'],4)
else
strZip:= LeftStr(COMPANY['ZIP'],5);
Lines.Clear;
if COMPANY['ADD1'] <> '' then
Lines.Add(COMPANY['ADD1']);
if COMPANY['ADD2'] <> '' then
Lines.Add(COMPANY['ADD2']);
if COMPANY['ADD3'] <> '' then
Lines.Add(COMPANY['ADD3']);
if COMPANY['CITY'] <> '' then
Lines.Add(COMPANY['CITY'] + ', ' + COMPANY['STATE'] + ' ' + strZip;
end;
Tks,
Don
This discussion has been closed.
Comments
For future reference, it is best to post RAP questions in the RAP newsgroup.
This helps us understand your question better and answer it quicker.
While in the code workspace (RAP), you will notice the Code Toolbox at the
bottom right corner. If you select the Language tab at the bottom then
select the String option from the listbox, you will see the available
built-in string functions you can use with RAP. Instead of using the
RightStr or LeftStr, you could use the Copy routine.
Note that RAP code is not Delphi code. RAP is its own language that is
compiled separate from Delphi. The syntax is that of pascal but it does not
have all the functionality of Delphi. It is possible to extend the RAP
language using a Delphi pass thru function. A complete example of creating
and using a pass thru function is available in the ReportBuilder Developer's
Guide.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks, this works for everyone's information...
var strZip : String;
begin
if Length(COMPANY['ZIP']) > 0 then
if Length(COMPANY['ZIP']) > 5 then
strZip:= Copy(COMPANY['ZIP'],1,5)+'-'+Copy(COMPANY['ZIP'],6,4)
else
strZip:= Copy(COMPANY['ZIP'],1,5);
Lines.Clear;
if COMPANY['ADD1'] <> '' then
Lines.Add(COMPANY['ADD1']);
if COMPANY['ADD2'] <> '' then
Lines.Add(COMPANY['ADD2']);
if COMPANY['ADD3'] <> '' then
Lines.Add(COMPANY['ADD3']);
if COMPANY['CITY'] <> '' then
Lines.Add(COMPANY['CITY'] + ', '+ COMPANY['STATE'] + ' ' + strZip);
end;
Tks,
Don