AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Split strings using string list

Ein Thema von WojTec · begonnen am 12. Aug 2011 · letzter Beitrag vom 12. Aug 2011
 
WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#1

Split strings using string list

  Alt 12. Aug 2011, 11:24
Delphi-Version: 2010
Delphi-Quellcode:
function GetBarcodeCode (intNR : integer; AIndex : integer = 7): ansistring;
var
 strReturn : ansistring;
 strParse : TStringList;
 strRow : TStringlist;
 strCode : ansistring;
begin
 strReturn := GetBarcodesResult;
 strCode := '';
 if strReturn <> 'then
     begin
      strParse := TStringList.Create;
      strRow := TStringList.Create;
      strParse.Delimiter := #13;
      strParse.Text := strReturn;
      strRow.Delimiter := #9;
      if intNr <= strParse.Count then
          begin
          strRow.DelimitedText := strParse.Strings [intNR - 1];
          strCode := strRow.strings [AIndex - 1];
          end;
      FreeandNil (strParse);
      FreeandNil (strRow);
     end;
 GetBarcodeCode := strCode;
end;
Here is real API function from real project called INBarcodeOCR. It is nice problem demonstration.

Siply, it splits string first by CR control character and then by tabs. Split by CR is ok, but by tabs is invalid in case if space is available in string. If space is in string then it splits it as if this space is tab strRow should contain 8 items, because always in string are 7 tabs, but if space is inside, then it working as for 8 tabs

This is class bug or code is buggy? Can fix it using build-in Delphi functions?
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:50 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz