Autor Beitrag
Arne Danikowski
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 194



BeitragVerfasst: Mi 20.01.10 15:20 
Hallo, ich möchte folgendes realisieren

Ein kleinen Programm, mit zwei Editfeldern und einen Button.

In das erste Editfeld möchte ich den Startwert angeben. In das zweite Editfeld den Endwert.
Dann soll das Programm Verzeichnisse anlegen.

Also z.B.
Startwert = A100
Endwert = A150

Dann sollen die Verzeichnisse A100,A101,A102,A103.... und so weiter bis A150 Angelegt werden

Ich stehe da wohl auf den Schlau. Denn A100 ist ja kein gültiger Integer Wert wie aber soll ich den hochzählen
guinnes
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 182
Erhaltene Danke: 14



BeitragVerfasst: Mi 20.01.10 15:25 
Indem du das A vorher abscheidest ?
Arne Danikowski Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 194



BeitragVerfasst: Mi 20.01.10 15:28 
Ok das war leicht :)
und wie muss nun die schleife aussehen?
Horst_H
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1654
Erhaltene Danke: 244

WIN10,PuppyLinux
FreePascal,Lazarus
BeitragVerfasst: Mi 20.01.10 15:35 
Hallo

ala
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
For i := Alpha bis Omega do
  begin
  VerzName := Format('A%.4d',[i]);// Hoffentlich richtig 4 Stellen mit Vornullen
  //VerzName := 'A'+IntToStr(i); 
  ...
  end;


Gruß Horst
guinnes
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 182
Erhaltene Danke: 14



BeitragVerfasst: Mi 20.01.10 15:36 
Führenden Buchstaben abschneiden, den Rest in einen Integer umwandeln, genauso mit der 2. Eingabe und schon hast du unter und Obergrenze für die Schleife
Arne Danikowski Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 194



BeitragVerfasst: Mi 20.01.10 15:42 
Ok ich habe es jetzt so gemacht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm5.Button1Click(Sender: TObject);
var start,stop:String;
    start2,stop2,rech:Integer;
begin
start2:=StrtoInt(edit1.Text);
stop2:=StrtoInt(edit2.Text);

while start2 < stop2 do
begin
start:='A';
start:=start+IntToStr(start2);
if DirectoryExists(start) = false then
CreateDir(start);
start2:=start2+1;

end;
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mi 20.01.10 18:22 
Ich hätts eher so gemacht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm5.Button1Click(Sender: TObject);
  var start,stop:String;
      start2,stop2,rech:Integer;
begin
  start2:=StrtoInt(edit1.Text);
  stop2:=StrtoInt(edit2.Text);
  while start2 < stop2 do begin
    start:='A'+IntToStr(start2);
    if not (DirectoryExists(start)) then
      CreateDir(start);
    inc(start2)
  end;
end;


eine zeile eingespart bei Start := 'A'; (is ja eigentlich unnötig das in 2 Befehlen zu machen). Bei der if Abfrage ist es eindeutig besser (vom programmierstil) wenn man auf not (Expression) abfragt als auf Expression =false. bei start2 := start2+1; mit Inc(Start2); ersetzt, weils kürzer und übersichtlicher ist. ;)

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.