Ver Mensaje Individual
  #11  
Antiguo 30-05-2007
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Reputación: 26
seoane Va por buen camino
Bueno, no creo que a los de borland les importe mucho que partiendo del método SetDelimitedText y recortando aquí y allá, lleguemos a esto:
Código Delphi [-]
procedure SetDelimitedText(StringList: TStringList; const Str: string);
var
  P, P1: PChar;
  S: string;
begin
  with StringList do
  begin
    BeginUpdate;
    try
      Clear;
      P := PChar(Str);
      while P^ <> #0 do
      begin
        if P^ = QuoteChar then
          S := AnsiExtractQuotedStr(P, QuoteChar)
        else
        begin
          P1 := P;
          while (P^ <> #0) and (P^ <> Delimiter) do
            P := CharNext(P);
          SetString(S, P1, P - P1);
        end;
        Add(S);
        if P^ = Delimiter then
        begin
          P:= CharNext(P);
          if P^ = #0 then
            Add('');
        end;
      end;
    finally
      EndUpdate;
    end;
  end;
end;

Por ejemplo:
Código Delphi [-]
var
  Lista: TStringList;
begin
  Lista:= TStringList.Create;
  try
    SetDelimitedText(Lista,'0001,GERARDO PEREZ GALINDO, GALEANA 211, 3949588');
    ShowMessage(Lista.Text);
  finally
    Lista.Free;
  end;
end;
Seguimos teniendo que traducirlo a C, pero teniendo en cuenta que se hace un uso intensivo de punteros, creo que el paso a C tendría que ser sencillo.

PD: Creo que ya lo dije antes, pero en el nuevo turbo la propiedad StrictDelimiter soluciona este problema.

Última edición por seoane fecha: 30-05-2007 a las 19:46:40.
Responder Con Cita