RP50001,201232,London;RP50002,201392,USAetc
OnRun() SemiColon := ';'; Comma := ','; String := 'RP50001,201232,London;RP50002,201392,USA'; String2 := Split(String, SemiColon, Pos); WHILE Pos > 0 DO BEGIN MESSAGE(String2); String := COPYSTR(String, Pos+1); String3 := Split(String2, Comma, Pos); WHILE Pos > 0 DO BEGIN MESSAGE(String3); String2 := COPYSTR(String2, Pos+1); String3 := Split(String2, Comma, Pos); END; IF String3 <> '' THEN MESSAGE(String3); String2 := Split(COPYSTR(String, Pos+1), SemiColon, Pos); END; IF String2 <> '' THEN BEGIN String3 := Split(String2, Comma, Pos); WHILE Pos > 0 DO BEGIN MESSAGE(String3); String2 := COPYSTR(String2, Pos+1); String3 := Split(String2, Comma, Pos); END; IF String3 <> '' THEN MESSAGE(String3); END; LOCAL Split(String : Text;Sep : Text[1];VAR Pos : Integer) : Text Pos := STRPOS(String, Sep); IF Pos > 0 THEN EXIT(COPYSTR(String, 1, Pos-1)) ELSE EXIT(String);
Answers
Take a look at this, i havent added a example for split, but if you know C#, then you should feel right at home.
https://juhl.blog/2017/04/24/text-manipulation-using-net/
Looking forward.
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
As suggested, .NET is your friend. Here is an example:
SemiColon := ';';
Comma := ',';
String := 'RP50001,201232,London;RP50002,201392,USA';
FOREACH SemiColonStrings IN String.Split(SemiColon.ToCharArray) DO BEGIN
MESSAGE('%1', SemiColonStrings);
FOREACH CommaStrings IN SemiColonStrings.Split(Comma.ToCharArray) DO BEGIN
MESSAGE('%1', CommaStrings);
END;
END;
where variables are:
It's translated into C# anyway
https://juhl.blog/2017/04/24/cal-vs-c-i-dynamics-nav/
Every variable is Text except Pos that is Integer.
Regards.
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
Ok, and that solved the problem or not ?
Regards
Entry(PintEntry : Integer;PtexEntries : Text[1024];PtexSeperator : Text[1]) PtexReturnValue : Text[1024]
// Entry
// gives anentry of a list base on an integer
// (like Navision SELECTSTR, but without bugs)
// PARAMETERS :
// PintEntry : which element must be returned
// IF (PintElement <= 0) OR (PintElement > NumEntries(PtexEntries,PtexSeperator))
// THEN '' is returned
// PtexEntries : list
// PtexSeperator : charakter used as seperator
// if = '' then ',' is used
// PtexReturnValue : selected element
PtexReturnValue := '';
LintLength := STRLEN(PtexEntries);
IF (LintLength = 0) OR
(PintEntry <= 0) THEN
EXIT('');
IF PtexSeperator = '' THEN
PtexSeperator := ',';
Lint := 0;
WHILE Lint < LintLength DO BEGIN
Lint := Lint + 1;
IF COPYSTR(PtexEntries,Lint,1) = PtexSeperator THEN
PintEntry := PintEntry - 1
ELSE IF PintEntry = 1 THEN
PtexReturnValue := PtexReturnValue + COPYSTR(PtexEntries,Lint,1);
END;
EXIT(PtexReturnValue);
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!