IF gItemNo <> '' THEN BEGIN IF STRPOS(gItemNo,'|') = 0 THEN BEGIN lRecItem2.RESET; lRecItem2.SETRANGE("Balance Code","Balance Code"); lRecItem2.SETRANGE("No.",gItemNo); IF NOT lRecItem2.FINDSET THEN ERROR(Text0001,gItemNo); END ELSE BEGIN END; END;
IF gItemNo <> '' THEN BEGIN IF STRPOS(gItemNo,'|') = 0 THEN BEGIN lRecItem2.RESET; lRecItem2.SETRANGE("Balance Code","Balance Code"); lRecItem2.SETRANGE("No.",gItemNo); IF NOT lRecItem2.FINDSET THEN ERROR(Text0001,gItemNo); END ELSE BEGIN SplitString(gItemNo,'|',ResultArray); FOR i := 0 TO ResultArray.Length - 1 DO BEGIN lRecItem2.RESET; lRecItem2.SETRANGE("Balance Code","Balance Code"); lRecItem2.SETRANGE("No.",FORMAT(ResultArray.GetValue(i))); IF NOT lRecItem2.FINDSET THEN ERROR(Text0001,gItemNo); END; END; END;
TextToSplit DotNet System.String.'mscorlib DelimiterText DotNet System.String.'mscorlib
LOCAL SplitString(_StringToSplit : Text;_Delimiter : Text;VAR _ResultArray : DotNet "System.Array") TextToSplit := _StringToSplit; DelimiterText := _Delimiter; _ResultArray := TextToSplit.Split(DelimiterText.ToCharArray());
ResultArray : DotNet "System.Array"
IF STRPOS(gItemNo,'|') = 0 THEN BEGIN lRecItem2.RESET; lRecItem2.SETRANGE("Balance Code","Balance Code"); lRecItem2.SETRANGE("No.",gItemNo); IF NOT lRecItem2.FINDSET THEN ERROR(Text0001,gItemNo); END ELSE BEGIN
FoundText Text FoundPos Integer
LOCAL SplitStringWithoutDotNET(_TextToSplit : Text[100];_Delimiter : Text;VAR TmpItem : TEMPORARY Record Item) IF NOT TmpItem.ISTEMPORARY THEN ERROR('no good idea'); TmpItem.RESET; IF NOT TmpItem.ISEMPTY THEN TmpItem.DELETEALL; FoundPos := STRPOS(_TextToSplit,_Delimiter); WHILE (FoundPos <> 0) DO BEGIN FoundText := COPYSTR(_TextToSplit,1,FoundPos-1); _TextToSplit := COPYSTR(_TextToSplit,FoundPos+1); FoundPos := STRPOS(_TextToSplit,_Delimiter); IF (FoundText <> '') AND (NOT TmpItem.GET(FoundText)) THEN BEGIN TmpItem.INIT; TmpItem."No." := FoundText; TmpItem.INSERT; END; END; IF (_TextToSplit <> '') AND (NOT TmpItem.GET(_TextToSplit)) THEN BEGIN TmpItem.INIT; TmpItem."No." := _TextToSplit; TmpItem.INSERT; END;
Answers
you could split the string with the help of .net.
The SplitString Function is like this ...
Locals:
And you need also a Local in your caller segment to handle the result.
Hope this helps
EDIT
I guess you can delete this code too ... Split gives you the result in index 0 even if there is no delimiter. In your case the first item.
EDIT2
As you posted this in Classic Client section there might be a chance that you can not use .net
So here for this scenario. The result is a temporary item table and you can simply loop through this.
Locals:
thinknavblog.wordpress.com
EDIT: Well both ways would work, Thank you again