Hi
As i am new to BC programming I am unsure of the correct syntax to find a new line in Text string. Can anyone advise?
Hi
As i am new to BC programming I am unsure of the correct syntax to find a new line in Text string. Can anyone advise?
Thanks all for the help.
I solved it using the following in the end...
var
typehelp: Codeunit "Type Helper";
crlf: Text[2];
begin
crlf := typehelp.CRLFSeparator();
textstring := 'This is line1
this is line 2
this is line 3';
//find the first line break
crpos := strpos(longtextleftover, crlf[2] );
end
If it is in a string you import or get from another system you can also use the CHAR datatype to search for the value 10 or 13 that is the char values for linefeed and carriage return.
Hi, Lars' answer is very good, he splits the line based on the content of textstring.
But I would like to add some basic information
when you want to change a line in the text, just use '\'.
For example:
So use '\' will find a new line.
A simple example:
Hope this will help.
Thanks.
ZHU
Hello,
You got 2 out of 3 commands that you need :-), just add COPYSTR([String],[Position],[Length]);. Something like this:
begin
textstring := 'This is line1. this is line 2. this is line 3';
LinePos := StrPos(TextString, '.');
line1 := CopyStr(TextString, 1, LinePos);
TextString := CopyStr(TextString, LinePos + 1);
LinePos := StrPos(TextString, '.');
line2 := CopyStr(TextString, 1, LinePos);
TextString := CopyStr(TextString, LinePos + 1);
line3 := TextString;
Message(Line1 + '\' + Line2 + '\' + Line3);
end;
var
TextString, Line1, Line2, Line3 : Text;
LinePos: Integer;
Note, I have not tested this, and likely I got a position wrong a few places, so it likely needs to be adjusted. Add more MESSAGE to see how the string develops.
Once that works, of course then the next challenge would be to do this as a function, something like this:
WHILE STRPOS(TextString,'.') <> 0 DO
TextString := MyFunction(TextString);
hth
André Arnaud de Cal... 291,735 Super User 2024 Season 2
Martin Dráb 230,466 Most Valuable Professional
nmaenpaa 101,156