Don't understand the reply. The actual sErrors string is shown with Errors.
Where is the wrong variable?
Line 3.
You have 3 line:
1 - copy S2PARSE -> sERRORS
2 - S2PARSE is replace "Errors" make "|Errors:"
3 - Copy2SymDef is copy all character before "|".
line 3 you code is copy all character before "|"
string sErrors. But you code not replace sErrors but S2PARSE
better:
program test;
{$mode objfpc}{$H+}
uses
strutils;
var
S2PARSE:string='hello this is Errors and get for you';
sErrors:string;
begin
writeln('S2PARSE = "',S2PARSE,'"');
sErrors:=S2PARSE;
writeln('sErrors = "',sErrors,'"');
S2PARSE:=ReplaceStr(sErrors,'Errors','|Errors:');
writeln('S2PARSE = "',S2PARSE,'"');
S2PARSE:=Copy2SymbDel(S2PARSE,'|');
writeln('S2PARSE = "',S2PARSE,'"');
end.
output:
S2PARSE = "hello this is Errors and get for you"
sErrors = "hello this is Errors and get for you"
S2PARSE = "hello this is |Errors: and get for you"
S2PARSE = "hello this is "
@jamie:
yes, is true but depend what user JLWest want. I can no see with example code.
@JLWest:
Jamie is write about parsing and do correct...then example look more:
program test2;
{$mode objfpc}{$H+}
uses
strutils;
var
S2PARSE:string='hello this is Errors and get Errors for you with Errors that can Errors or not Errors some time';
sErrors:string;
sSymDel:string;
begin
writeln('S2PARSE = "',S2PARSE,'"');
sErrors:=S2PARSE;
writeln('sErrors = "',sErrors,'"');
S2PARSE:=ReplaceStr(sErrors,'Errors','|Errors:');
writeln('S2PARSE = "',S2PARSE,'"');
repeat
sSymDel:=Copy2SymbDel(S2PARSE,'|');
writeln('sSymDel = "',sSymDel,'"',' ':30-Length(sSymDel),'S2PARSE = "',S2PARSE,'"');
until sSymDel='';
end
output:
S2PARSE = "hello this is Errors and get Errors for you with Errors that can Errors or not Errors some time"
sErrors = "hello this is Errors and get Errors for you with Errors that can Errors or not Errors some time"
S2PARSE = "hello this is |Errors: and get |Errors: for you with |Errors: that can |Errors: or not |Errors: some time"
sSymDel = "hello this is " S2PARSE = "Errors: and get |Errors: for you with |Errors: that can |Errors: or not |Errors: some time"
sSymDel = "Errors: and get " S2PARSE = "Errors: for you with |Errors: that can |Errors: or not |Errors: some time"
sSymDel = "Errors: for you with " S2PARSE = "Errors: that can |Errors: or not |Errors: some time"
sSymDel = "Errors: that can " S2PARSE = "Errors: or not |Errors: some time"
sSymDel = "Errors: or not " S2PARSE = "Errors: some time"
sSymDel = "Errors: some time" S2PARSE = ""
sSymDel = "" S2PARSE = ""
How use Copy2SymbDel() is depend what want.