Also, ich habe mit meinem Programm vier typisierte Dateien erzeugt.
Beispielhaft dazu hier folgender Code:
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:
| type bestellungkast = record pos: integer; laenge: string[10]; anzahl: string[10]; kt: string[50]; groesse: string[50]; gurt: string[50]; welle: string[50]; motor: string[50]; end;
var Form6: TForm6; dateibestellkast: file of bestellungkast; implementation
{$R *.dfm}
procedure TForm6.Button2Click(Sender: TObject); var datensatz: bestellungkast; nr: integer; begin if Application.MessageBox ('Position in Auftrag übernehmen?', 'Rolladenpanzer',36) = 6 then begin if FilePos (dateibestellkast) <> 0 then Seek(dateibestellkast,FilePos(dateibestellkast)-1) else Seek(dateibestellkast,FilePos(dateibestellkast)); nr:=FilePos(dateibestellkast); datensatz.laenge:=Edit3.Text; datensatz.anzahl:=Edit5.Text; datensatz.kt:=ComboBox1.text; datensatz.groesse:=ComboBox2.Text; datensatz.gurt:=ComboBox3.text; datensatz.welle:=ComboBox4.Text; datensatz.motor:=ComboBox5.text; write(dateibestellkast,datensatz); positionieren(nr); end; end;
procedure TForm6.FormCreate(Sender: TObject); var datensatz: auftrag; begin AssignFile(dateibestellkast,'bestellungkast.dat'); if FileExists('bestellungkast.dat') then ReSet(dateibestellkast) else ReWrite(dateibestellkast);
end;
procedure TForm6.FormClose(Sender: TObject; var Action: TCloseAction); begin closefile (dateibestellkast); Action:= caFree; end; ... end. |
Neben dateibestellkast hab ich noch dateibestell, dateifirm und dateiauf
mit folgenden records erstellt:
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:
| type bestellungpanz = record pos: integer; breite: string[10]; hoehe: string[10]; anzahl: string[10]; pst: string[50]; fpst: string[50]; endl: string[50]; fendl: string[50]; stung: string[50]; aufh: string[50]; stopp: string[10]; abstli: string[10]; abstre: string[10]; end;
type firma = record name: string[100]; strasse: string[100]; plz: string[10]; ort: string[100]; end;
type auftrag = record kom: string[100]; lt: string[30]; end; |
Jetzt sollen diese Dateien irgendwie auf ein Blatt Papier gebracht werden.
In dateifirm und dateiauf steht jeweils nur ein Datensatz, die oben auf dem Blatt stehen sollen.
In dateibestell und dateibestellkast stehen mehrere Datensätze, die untereinander aufgelistet werden sollen.
Die Prozedur zum Ausdrucken hab ich mit folgendem Code erstellt.
Fehlermeldung: Array und Text passen nicht zusammen. (Printer.Canvas.TextOut(x, y, buffer1)
Hat das Programm wohl recht, aber was tun ?????????
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:
| procedure TForm5.Button5Click(Sender: TObject); var x, y: integer; breite, hoehe, randlinks, randoben: integer; dateifirm: file of firma; dateibestell: file of bestellungpanz; dateibestellkast: file of bestellungkast; Buffer1: array[0..BufferSize - 1] of firma; Buffer2: array[0..BufferSize - 1] of bestellungpanz; Buffer3: array[0..BufferSize - 1] of bestellungkast; Buffer4: array[0..BufferSize - 1] of auftrag; t: text; p: integer; begin if PrintDialog1.Execute then begin AssignFile (dateifirm, 'firma.dat'); AssignFile (dateibestell,'bestellung.dat'); AssignFile (dateibestellkast,'bestellungkast.dat'); reset(dateifirm); reset(dateibestell); reset(dateibestellkast); printer.Orientation:=poLandscape; Printer.BeginDoc;
breite:=GetDeviceCaps(Printer.Canvas.Handle, HORZSIZE)*10; hoehe:=GetDeviceCaps(Printer.Canvas.Handle, VERTSIZE)*10;
randlinks:=250; randoben:=250;
x:=randlinks; y:=randoben*-1;
SetMapMode(Printer.Canvas.Handle, MM_LOMETRIC);
Printer.Canvas.Font.Name:='Arial'; Printer.Canvas.Brush.Color:=clWhite; Printer.Canvas.Font.Height:=50;
Seek(dateifirm,0); p:=0;
while not eof (dateifirm) do begin Read(dateifirm, t); if -y>(hoehe-2*randoben) then begin y:=randoben*-1; Printer.NewPage; end;
while not eof (dateiauf) do begin Read(dateiauf, Buffer4[p]); if -y>(hoehe-2*randoben) then begin y:=randoben*-1; Printer.NewPage; end;
while not eof (dateibestell) do begin Read(dateibestell, Buffer2[p]); if -y>(hoehe-2*randoben) then begin y:=randoben*-1; Printer.NewPage; end;
while not eof (dateibestellkast) do begin Read(dateibestellkast, Buffer3[p]); if -y>(hoehe-2*randoben) then begin y:=randoben*-1; Printer.NewPage; end;
if y=-randoben then begin Printer.Canvas.Font.Style:=[fsbold]; Printer.Canvas.TextOut(x, y, 'Seite '+ IntToStr(Printer.PageNumber)); Printer.Canvas.Font.Style:=[]; end;
Printer.Canvas.TextOut(x, y, buffer1); Printer.Canvas.TextOut(x, y, buffer4); Printer.Canvas.TextOut(x, y, buffer2); Printer.Canvas.TextOut(x, y, buffer3);
end;
closefile (dateifirm); closefile (dateibestell); closefile (dateibestellkast);
Printer.EndDoc;
end; end; |
Wäre super, wenn mir jemand weiterhelfen könnte.
Moderiert von
UGrohne: Delphi-Tags eingefügt