AGB  ·  Datenschutz  ·  Impressum  







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

Problem mit StrPos/AnsiStrPos

Ein Thema von DevilsCamp · begonnen am 3. Dez 2005 · letzter Beitrag vom 3. Dez 2005
 
DevilsCamp
(Gast)

n/a Beiträge
 
#1

Problem mit StrPos/AnsiStrPos

  Alt 3. Dez 2005, 09:20
ich habe folgenden Code:

Delphi-Quellcode:
Procedure ReadSection(const Section: String; List: TStrings);
var
  p : PChar;
  f : PChar;
  g : PChar;
  s : String;
begin
  List.Clear;
  f := FStream.Memory;
  f[FStream.Size] := #0;
  p := StrPos(f, PChar(Format('[%s]', [Section])+#13#10));

  if (p<>nil) then
  begin
    f := StrPos(p, PChar(#13#10+'['));

    if (f=nil) then
      f := p+StrLen(p)-2;

    try
      GetMem(g, StrLen(p)+2);
      StrLCopy(g, p, f-p);

      p := StrPos(g, PChar(']'+#13#10))+3;
      f := p;
      p := StrPos(f, PChar('='));

      while (p<>nil) do
      begin
        SetString(s, f, p-f);
        List.Add(s);
        f := StrPos(p, Pchar(#13#10))+2;
        p := StrPos(f, PChar('='));
      end;

    finally
      FreeMem(g);
    end;
  end; // if (p<>nil)

end;
Dieser Code funktioniert so wie er soll, bis zu den Zeilen
Delphi-Quellcode:
p := StrPos(g, PChar(']'+#13#10))+3;
f := p;
p := StrPos(f, PChar('='));
Da bekomme ich dann eine "Access Violation" bei
p := StrPos(f, PChar('=')); die sich völlig meines Verständnisses entzieht.

Bei debuggen sehe ich auch, dass vor dieser Zeile f WIRKLICH gleich p ist und auch Text vorhanden ist (f und p sind NIChT nil und die Länge ist > 0)

Vielleicht kann mir einer helfen




PS:
Ich habe es auch schon AnsiStrPos statt StrPos versucht.
  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 23:49 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz