Gracias lord delfos por tus consejos, te cuento que estoy intantando hacer el cambio que me dijiste peor me salta un error que no logro corregir. Si no es mucha molestia te pediría queme orientes: te paso el codigo completo para que veas de que se trata
unit 1
Código:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, Unit2;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Archivo: TMainMenu;
ARCHIVO1: TMenuItem;
NUEVO1: TMenuItem;
ABRIR1: TMenuItem;
GUARDAR1: TMenuItem;
AGREGARALUMNO1: TMenuItem;
ELIMINARALUMNO1: TMenuItem;
CERRRA1: TMenuItem;
HERRAMIENTAS1: TMenuItem;
objectLabel5TLabel1: TMenuItem;
LISTACPROMEDIOS1: TMenuItem;
LISTADEREGULARES1: TMenuItem;
LISTADELIBRES1: TMenuItem;
SALIR1: TMenuItem;
Label8: TLabel;
Label9: TLabel;
Edit7: TEdit;
Button1: TButton;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
procedure NUEVO1Click(Sender: TObject);
procedure ABRIR1Click(Sender: TObject);
//procedure GUARDAR1Click(Sender: TObject);
procedure AGREGARALUMNO1Click(Sender: TObject);
procedure SALIR1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
//procedure ELIMINARALUMNO1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
z: TAdministrar;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
z:=TAdministrar.Create;
end;
procedure TForm1.NUEVO1Click(Sender: TObject);
begin
If SaveDialog1.Execute
then begin
z.ArchivoNuevo(Savedialog1.filename{+'.txt'});
showmessage('Se creó el archivo:'+Savedialog1.filename{+'.txt'})
end
end;
procedure TForm1.ABRIR1Click(Sender: TObject);
begin
If OpenDialog1.Execute
then begin
z.AbrirArchivo(OpenDialog1.filename);
showmessage('Archivo '+OpenDialog1.filename+' Abierto')
end
end;
procedure TForm1.AGREGARALUMNO1Click(Sender: TObject);
var a:Alumno; b:byte; z: TAdministrar;
begin
a.Apellido:=Edit2.Text;
a.Nombres:=Edit3.Text;
a.DNI:=StrToInt(Edit1.Text);
a.N1:=StrToInt(Edit4.Text);
a.N2:=StrToInt(Edit5.Text);
a.N3:=StrToInt(Edit6.Text);
z.AgregarAlumno(a,b);
If b<>0 then ShowMessage('No se pudo Agregar el Cliente.Seguramente no Abrió antes el archivo')
else ShowMessage('Se ha agregado el registro');
end;
procedure TForm1.SALIR1Click(Sender: TObject);
begin
Close;
end;
Unit2
Código:
unit Unit2;
interface
uses SysUtils,Dialogs;
Type
Alumno= Record
Apellido, nombres: string[20];
DNI:longint;
N1, N2, N3: real;
end;
TAdministrar=class
private
Archi: File of Alumno;
public
procedure ArchivoNuevo(ArchiFisico:string);
procedure AbrirArchivo(ArchiFisico:string);
procedure AgregarAlumno(a:Alumno; var b:byte);
//procedure borrarArchivo(p:word; a:Alumno; var cod:byte; m:string);
//procedure BuscarCliente(p:word; var c:Cliente; var m:string);
//procedure CerrarArchivo;
end;
implementation
procedure TAdministrar.ArchivoNuevo(ArchiFisico:string);
var archi:textfile;
begin
AssignFile(Archi,ArchiFisico);
Rewrite(Archi);
end;
procedure TAdministrar.AbrirArchivo(ArchiFisico:string);
var archi:textfile;
begin
AssignFile(Archi,ArchiFisico);
Reset(Archi)
end;
procedure TAdministrar.AgregarAlumno(a:Alumno; var b:byte);
begin
{$I-}
Seek(Archi, FileSize (archi));
{$I+};
b:=IOResult;
If b=0 then
Writeln(Archi, a.Apellido);
Writeln(Archi, a.Nombres);
Writeln(Archi, a.DNI);
Writeln(Archi, a.N1);
Writeln(Archi, a.N2);
Writeln(Archi, a.N3);
end;
end.
Me saltan los siguientes errores:
[Error] Unit2.pas(52): Incompatible types: 'Alumno' and 'ShortString'
[Error] Unit2.pas(53): Illegal type in Write/Writeln statement
[Error] Unit2.pas(53): Incompatible types: 'Alumno' and 'ShortString'
[Error] Unit2.pas(54): Illegal type in Write/Writeln statement
Muchisimas gracias!!!