Autor Beitrag
Conny Drexler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44


D6 prof. win xp
BeitragVerfasst: Mo 02.06.03 22:19 
Ich habe ein Problem mit einer Routine zum wegschreiben von Datensätzen (Strings) in eine Ascii Datei. Nach neunmaligem Aufruf reagiert mein Programm einfach nicht mehr. Woran liegt das??? Nachfolgend die Routine:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
unit unpv;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,
  utypen,uconst,uinit, ComCtrls;

type
  TFnpv = class(TForm)
    ComboBox1: TComboBox;
    ProgressBar1: TProgressBar;
    Label1: TLabel;
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

const cunpv = ' - 1.02/030601';

var
  Fnpv: TFnpv;


procedure npv(rechnungszeile:tzeile);


implementation

{$R *.dfm}


procedure npv(rechnungszeile:tzeile);
Var datensatz : zeile;
    gefunden : boolean;
    zaehler, z : integer;
Begin
  if not(npvdef) then
    Begin
      fnpv.Caption := fnpv.Caption + cunpv;
      gefunden := false;
      fnpv.Visible := true;
      assignfile(eandatei,eandateiname);
      reset(eandatei);
      fnpv.ProgressBar1.Max := filesize(eandatei);
      fnpv.ProgressBar1.Min := 0;
      fnpv.ProgressBar1.Step := 1;
      fnpv.ComboBox1.Items.Clear;
      fnpv.ComboBox1.SelText := '';
      while not(eof(eandatei)) or (gefunden) do
        Begin
          init_ean(ean);
          read(eandatei,ean);
          str(ean.artikelnummer,dummy_zeile);
          datensatz := copy(trim(dummy_zeile) + leerstring,1,30);
          datensatz := datensatz + ean.eanstring;
          fnpv.ComboBox1.Items.Add(datensatz);
          fnpv.ProgressBar1.StepIt;
        end;    // while
      closefile(eandatei);
      fnpv.Visible := false;
      npvdef := true;
//      assignfile(npvdatei,konfig.arbeitsverzeichnis + '\' +  npvdateiname);
      reset(npvdatei);
      append(npvdatei);
    end;
//  assignfile(npvdatei,konfig.arbeitsverzeichnis + '\' +  npvdateiname);
//  reset(npvdatei);
  append(npvdatei);
  if rechnungszeile.artikel.EAN then
    Begin
      zaehler := 0;
      str(rechnungszeile.artikel.Artikelnummer,dummy_zeile);
      repeat
        datensatz := trim(copy(fnpv.ComboBox1.Items.Strings[zaehler],1,30));
        inc(zaehler);
      until (trim(datensatz) = trim(dummy_zeile));
      dummy_zeile := fnpv.ComboBox1.Items.Strings[zaehler - 1];
    end;
  datensatz := trim(copy(dummy_Zeile,29,length(dummy_zeile))) + '00000' + ehnummer + '000000';
  konfig.arbeitsdatum := date;
  dummy_zeile := datetostr(konfig.arbeitsdatum);
  delete(dummy_zeile,3,1);
  delete(dummy_zeile,5,1);
  insert('20',dummy_zeile,5);
  datensatz := datensatz + dummy_zeile;

  konfig.uhrzeit := time;
  dummy_zeile := timetostr(konfig.uhrzeit);
  delete(dummy_zeile,3,1);
  delete(dummy_zeile,5,1);
  datensatz := datensatz + dummy_zeile;
  str(rechnungszeile.anzahl:3:0,dummy_zeile);
  dummy_zeile := '0000' + trim(dummy_zeile);
  dummy_zeile := copy(dummy_zeile,length(dummy_zeile)-2,length(dummy_zeile));
  datensatz := datensatz + dummy_zeile;
//  datensatz := copy(datensatz,2,length(dummy_zeile));
  valok := length(datensatz);
  str(valok,dummy_zeile);
  if valok = 51 then
    writeln(npvdatei,datensatz)
  else
    showmessage('Zeitung nicht in NPV - Datei geschrieben!' + #10 +
      'Zeitschrift: *** ' + rechnungszeile.artikel.Artikelbezeichnung + ' ***' + #10 +
        'Bitte EAN überprüfen.');
  fnpv.Visible := true;
  for zaehler := 1 to 10 do
    for z := -32767 to 32767 do
      Begin
        str(zaehler,dummy_zeile);
        fnpv.Label1.caption := dummy_zeile;
        fnpv.Update;
        datensatz := '*****';
      end;
//  closefile(npvdatei);
  fnpv.Visible := false;
  fnpv.Close;
end;


end.



Moderiert von user profile icontommie-lie: Delphi-Tags hinzugefügt
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mo 02.06.03 22:28 
Hi,

kleiner Tipp am Rande: formatier den Code.

Zu den Abstürzen: kein PC hat unendlich Ressourcen - Rechenleistung und RAM sind (leider) endliche Größen.

AXMD
Conny Drexler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44


D6 prof. win xp
BeitragVerfasst: Di 03.06.03 12:12 
Titel: Danke für den Tip
Danke für den freundlichen Hinweis zwecks Speicher usw. und wie mache ich Speicher wieder frei oder belege diesen anders????