Creating a calculation I cant seem to find the property that tells me how many lines are in the memo field. Normally I would try Memo.Count but no luck. How can I scroll through each line of a memo in RAP?
The memo wrapping is determined when the memo control is told to generate. One way to do this when the report is running is to use the Memo's OnDrawCommandCreate event. Typecast the drawcommand parameter as a TppDrawText and then lcheck its WrappedText TStrings property. This should be the lines and count you are after.
Also, you'll need to add ppDrwCmd to your uses clause.
What if I just scroll through Lines[0], Lines[1], Lines[2] etc. The only question would be how to trap the error for a line outside the last line number? Alternatively, can you give me an example of code that would take a memo and concatenate the lines into one long string?
If you want to get the memo as one line then when the memo goes to print, call myLocalStringVar := Memo1.Lines.Text or pull the memo data directly from the datapipeline and place it in a string variable.
If you are using a Memo control that the user entered data for, and not a DBMemo, then simply reference the Memo1.Lines.Count and then loop through the Memo1.Lines[] TStrings (TStringList) property.
I still haven't been able to do what I want despite all the help.
My requirement is (from end-user RAP, not Delphi) to obtain a multi-lined memo field and display it as a single line. The memo in question is a multi-lined address field. Ideally I would like to separate each line of information on one line but separated buy a comma, but I can get by with spaces if this would work.
How can I do this? Is there no way in RAP to obtain a line count?
As an end user in RAP, there are string functions surfaced. Use a TppLabel to show the memo data in one line out-of-the-box. If you want commas then code its OnGetText event. Read the data straight from the pipeline to a string variable. Then parse out the #13#10 CRLF characters using Pos() and Copy() functions surfaced in RAP. Then you should be able to perform any string manipulation that you want to have commas or spaces bewteen the lines in one line.
{RAP code} procedure Label1OnGetText(var Text: String); var lsText: String; begin lsText := JITPipeline1['MemoLines']; //a memo field with hard returns in it Text := ProcessTheAddress(lsText); end;
{Delphi code- data retrieved in a JIT for testing}
function TmyEndUserSolution.ppJITPipeline1GetFieldValue(aFieldName: String): Variant; begin
if (aFieldName = 'MemoLines') then begin Result := '4550 Bigtoe Road' + #13#10; Result := Result + 'Superior, Colorado' + #13#10; Result := Result + '12345'; end;
Comments
One way to do this when the report is running is to use the Memo's
OnDrawCommandCreate event. Typecast the drawcommand parameter as a
TppDrawText and then lcheck its WrappedText TStrings property. This should
be the lines and count you are after.
Also, you'll need to add ppDrwCmd to your uses clause.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
What if I just scroll through Lines[0], Lines[1], Lines[2] etc. The only
question would be how to trap the error for a line outside the last line
number? Alternatively, can you give me an example of code that would take a
memo and concatenate the lines into one long string?
Thankyou
Alex
call myLocalStringVar := Memo1.Lines.Text or pull the memo data directly
from the datapipeline and place it in a string variable.
If you are using a Memo control that the user entered data for, and not a
DBMemo, then simply reference the Memo1.Lines.Count and then loop through
the Memo1.Lines[] TStrings (TStringList) property.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I still haven't been able to do what I want despite all the help.
My requirement is (from end-user RAP, not Delphi) to obtain a multi-lined
memo field and display it as a single line. The memo in question is a
multi-lined address field. Ideally I would like to separate each line of
information on one line but separated buy a comma, but I can get by with
spaces if this would work.
How can I do this? Is there no way in RAP to obtain a line count?
Regards
Alex
to show the memo data in one line out-of-the-box. If you want commas then
code its OnGetText event. Read the data straight from the pipeline to a
string variable. Then parse out the #13#10 CRLF characters using Pos() and
Copy() functions surfaced in RAP. Then you should be able to perform any
string manipulation that you want to have commas or spaces bewteen the lines
in one line.
{RAP code}
procedure Label1OnGetText(var Text: String);
var
lsText: String;
begin
lsText := JITPipeline1['MemoLines']; //a memo field with hard returns in
it
Text := ProcessTheAddress(lsText);
end;
{Delphi code- data retrieved in a JIT for testing}
function TmyEndUserSolution.ppJITPipeline1GetFieldValue(aFieldName: String):
Variant;
begin
if (aFieldName = 'MemoLines') then
begin
Result := '4550 Bigtoe Road' + #13#10;
Result := Result + 'Superior, Colorado' + #13#10;
Result := Result + '12345';
end;
end;
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com