Autor Beitrag
moloch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Fr 15.10.04 11:51 
hallo,
wie kriegt man raus ob assignfile etwas leeres zurückgibt?

mfg
moloch
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Fr 15.10.04 11:53 
Siehe Hilfe zu AssignFile:
Die Delphi-Hilfe hat folgendes geschrieben:
Call AssignFile to initialize a file variable. F is a file variable of any file type. FileName is a string-type expression or an expression of type PChar if extended syntax is enabled.

After calling AssignFile, F is associated with the external file until F is closed. All further operations on the file variable F operate on the external file named by FileName.

When the FileName parameter is empty, AssignFile associates F with the standard input or standard output file. If assigned an empty name, after a call to Reset (F), F refers to the standard input file, and after a call to Rewrite (F), F refers to the standard output file.

Do not use AssignFile on a file variable that is already open.

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Fr 15.10.04 11:55 
standard input output??
kann ich f=nil abfragen?

mfg
moloch
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Fr 15.10.04 11:59 
moloch hat folgendes geschrieben:
standard input output??
kann ich f=nil abfragen?

Tastatur, Bildschirm, nein.

Wenn du mehr Comfort suchst, solltest du vielleicht TFileStream verwenden.

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Fr 15.10.04 12:02 
nicht comfort, ich hab aber nicht ganz verstanden wie ich jetzt abfrage ob der rückgabewert leer ist.

mfg
moloch
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 15.10.04 12:17 
AssignFile weist doch einer Dateivariablen nur den Dateinamen zu.
Erst Reset/Rewrite/Append sorgen für den physischen Zugriff. Dort kann man dann mit Try...Except anfangen etwas zu prüfen.
Wenn du wissen willst, ob eine Datei existiert, nimm doch FileExist.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 15.10.04 12:18 
Wie gesagt, gar nicht. Du kannst nur nach Reset, Rewrite oder Append den Wert von IOResult prüfen.
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Fr 15.10.04 12:26 
und wie sieht das dann genau aus?
mfg
moloch
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 15.10.04 12:30 
Schau mal in die OH. Dort sind normalerweise auch Beispiele. Ansonsten funktioniert die Suchfunktion im Forum wieder.
Zeig doch mal ein bisschen Eigenitiative. Dabei lernst du bestimmt mehr, als wenn wir dir code-Fragmente posten.
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Fr 15.10.04 12:30 
ausblenden Delphi-Quelltext
1:
2:
3:
{$I-} //ganz wichtig
...
if IOResult <> 0 then //Fehler

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Fr 15.10.04 12:38 
ok danke schön.
ich habe das nicht gefunden im beispiel meiner delphi-hilfe.ansonsten ist es natürlich richtig das ich nicht lerne wenn ihr mir nur den code schreibt

mfg
moloch
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 15.10.04 12:50 
Beispiel aus der OH zu IOResult in D5Pro:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
var 

  F: file of Byte;
begin
  if OpenDialog1.Execute then begin
    AssignFile(F, OpenDialog1.FileName);
    {$I-}
    Reset(F);
    {$I+}
    if IOResult = 0 then
      MessageDlg('Dateigröße in Bytes: ' + IntToStr(FileSize(F)), 
        mtInformation, [mbOk], 0)
    else
      MessageDlg('Fehler bei Dateizugriff', mtWarning, [mbOk], 0);
  end;
end;

Ist nicht böse gemeint, aber übe doch mal mit der OH.
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Fr 15.10.04 13:35 
hey peter
das ist nett
danke schön.
falls wir uns nicht mehr hören wünsch ich dir ein schönes wochenende

mfg
moloch