Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Problem mit StringList (https://www.delphipraxis.net/26300-problem-mit-stringlist.html)

Andreas L. 21. Jul 2004 16:58


Problem mit StringList
 
Hi,
ich habe folgenden Code.

Delphi-Quellcode:
procedure TForm1.Button3Click(Sender: TObject);
var
 i : Integer;
 linkparam : String;
 sl : TStringList;
begin
 if Savedialog1.Execute then
  begin
   linkparam:=Edit1.Text;
   sl:=TStringList.create;
   sl.Add('<?php');
   sl.Add('if(isset($HTTP_GET_VARS["'+linkparam+'"])){$'+linkparam+' = $HTTP_GET_VARS["'+linkparam+'"];}else{$'+linkparam+' = "";}');
   sl.Add('           switch($'+linkparam+')');
   sl.Add('            {');
   for i:=0 to ListBox1.ItemIndex-1 do
    begin
     sl.Add('case "'+ ListBox1.Items.Strings[i] +'": header(Location: '+ ListBox2.Items.Strings[i] +'"); break;');
    end;
   sl.Add('            }');
   sl.add('?>');
   sl.SaveToFile(savedialog1.FileName);
  end
end;
Diese Zeile
Delphi-Quellcode:
sl.Add('case "'+ ListBox1.Items.Strings[i] +'": header(Location: '+ ListBox2.Items.Strings[i] +'"); break;');
funktioniert nicht. Führe ich die procedure aus wird anscheinend die ganze for-Schleife nicht beachtet.

Das das fertige Dokument dann so aussieht:

Code:
<?php
if(isset($HTTP_GET_VARS["page"])){$page = $HTTP_GET_VARS["page"];}else{$page = "";}
            switch($page)
             {
             }
?>
Wer findet den fehler, bin ratlos.....?

Greetz und thx

rantanplan99 21. Jul 2004 17:06

Re: Problem mit StringList
 
Zitat:

Delphi-Quellcode:
   for i:=0 to ListBox1.ItemIndex-1 do
    begin
     sl.Add('case "'+ ListBox1.Items.Strings[i] +'": header(Location: '+ ListBox2.Items.Strings[i] +'"); break;');
    end;

probiers mal mit
Delphi-Quellcode:
   for i:=0 to ListBox1.Count-1 do
    begin
     sl.Add('case "'+ ListBox1.Items.Strings[i] +'": header(Location: '+ ListBox2.Items.Strings[i] +'"); break;');
    end;
Itemindex liefert ja nur den Index des selektierten Items zurück und ich nehme an du meinst .count

Andreas L. 21. Jul 2004 17:11

Re: Problem mit StringList
 
OK, jezt gehts.

Danke

Giantics 21. Jul 2004 17:11

Re: Problem mit StringList
 
Mir fällt da grad noch auf, dass du die Stringliste nach Gebrauch nicht wieder löschen tust (sl.Free) 8)


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:38 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-2025 by Thomas Breitkreuz