aqui esta la undiad tipos
Código:
unit Tipos;
interface
uses
Controls;
type
TPeriodoMedicion = (Manhana, Tarde, Noche);
TTipoMedicion = (Diastolica, Sistolica);
TMedicionPresion = record
ValorMedicion: Integer;
PeriodoMedicion : TPeriodoMedicion;
TipoMedicion : TTipoMedicion;
Fecha : TDate;
end;
implementation
end.
aqui esta la unidad de los datos que es doden lso ingreso
Código:
unit U_Datos;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Tipos, ComCtrls;
type
TFrm_Datos = class(TForm)
Rdg_presionesart: TRadioGroup;
Label1: TLabel;
Label2: TLabel;
Tcom_estadodeldia: TComboBox;
Edt_ValorPresion: TEdit;
Btn_Guardar: TButton;
DateTimePicker1: TDateTimePicker;
Label3: TLabel;
procedure Rdg_presionesartClick(Sender: TObject);
procedure Btn_GuardarClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_Datos: TFrm_Datos;
implementation
{$R *.dfm}
procedure TFrm_Datos.Rdg_presionesartClick(Sender: TObject);
begin
if Frm_Datos.Rdg_presionesart.ItemIndex = 0 then
begin
Frm_Datos.Label1.Caption := 'Sistolica:';
end
else
begin
Frm_Datos.Label1.Caption := 'Diastolica:';
end
end;
procedure TFrm_Datos.Btn_GuardarClick(Sender: TObject);
var
LaMedicionPresion : TMedicionPresion;
F : TextFile;
SArchivo: String;
begin
LaMedicionPresion.ValorMedicion := StrToInt(Edt_ValorPresion.text);
LaMedicionPresion.Fecha := self.DateTimePicker1.Date;
if frm_Datos.Rdg_presionesart.ItemIndex = 0 then
begin
LaMedicionPresion.TipoMedicion := Sistolica;
end
else
begin
LaMedicionPresion.TipoMedicion := Diastolica;
end;
if frm_Datos.Tcom_estadodeldia.ItemIndex = 0 then
LaMedicionPresion.PeriodoMedicion := Manhana
else if frm_Datos.Tcom_estadodeldia.ItemIndex = 1 then
LaMedicionPresion.PeriodoMedicion := Tarde
else if frm_Datos.Tcom_estadodeldia.ItemIndex = 2 then
LaMedicionPresion.PeriodoMedicion := Noche;
sArchivo := ExtractFilePath( Application.ExeName ) + 'Registros.txt';
AssignFile(F, 'Registros.txt');
if FileExists( sArchivo ) then
Append( F )
else
begin
Rewrite( F );
// Escribir una linea
Writeln(F, 'Registro Dato Presion');
end;
Writeln(F, '');
Writeln(F, IntToStr(LaMedicionPresion.ValorMedicion) );
if LaMedicionPresion.PeriodoMedicion = Manhana then
Writeln(F, 'Mananha' )
else if LaMedicionPresion.PeriodoMedicion = Tarde then
Writeln(F, 'Tarde' )
else if LaMedicionPresion.PeriodoMedicion = Noche then
Writeln(F, 'Noche' );
if LaMedicionPresion.TipoMedicion = Diastolica then
Writeln(F, 'Diastolica' )
else if LaMedicionPresion.tipoMedicion = Sistolica then
Writeln(F, 'Sistolica' );
Writeln(F, DateToStr(LaMedicionPresion.Fecha ) );
CloseFile(F);
self.Edt_ValorPresion.Clear;
end;
end.
y aqui esta dodne lso cargo apra utilizarlos en las oepraciones+ç
Código:
unit U_Acerca_De;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, tIPOS;
type
TFrm_Acerca_de = class(TForm)
Label1: TLabel;
Image2: TImage;
StaticText1: TStaticText;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_Acerca_de: TFrm_Acerca_de;
Numero_datos_A_Analizar: integer;
DatosMedicion : array of TMedicionPresion;
implementation
{$R *.dfm}
procedure TFrm_Acerca_de.FormCreate(Sender: TObject);
var
F : TextFile;
linealeida: String;
begin
assignfile(F, 'registros.txt');
Reset(F);
Readln(F, LineaLeida);
while not Eof(F) do
begin
// Leer las variables X y Y del punto desde el archivo
Readln(F, LineaLeida);
LineaLeida := Trim(LineaLeida);
// Necesito que no me tenga en cuenta los espacios
if Length(LineaLeida) > 0 then
begin
Numero_datos_a_Analizar := Numero_datos_a_Analizar + 1;
// Ingresar a la matriz de puntos
SetLength(DatosMedicion, Numero_datos_a_Analizar);
Datosmedicion[Numero_datos_a_Analizar - 1].ValorMedicion := StrToInt(LineaLeida);
Readln(F, LineaLeida);
LineaLeida := Trim(LineaLeida);
if LineaLeida = 'Mananha' then
Datosmedicion[Numero_datos_a_Analizar - 1].PeriodoMedicion := Manhana
else if LineaLeida = 'Tarde' then
Datosmedicion[Numero_datos_a_Analizar - 1].PeriodoMedicion := Tarde
else if LineaLeida = 'Noche' then
Datosmedicion[Numero_datos_a_Analizar - 1].PeriodoMedicion := Noche;
Readln(F, LineaLeida);
LineaLeida := Trim(LineaLeida);
if LineaLeida = 'Sistolica' then
Datosmedicion[Numero_datos_a_Analizar - 1].TipoMedicion := Sistolica
else if LineaLeida = 'Diastolica' then
Datosmedicion[Numero_datos_a_Analizar - 1].TipoMedicion := Diastolica;
Readln(F, LineaLeida);
LineaLeida := Trim(LineaLeida);
Datosmedicion[Numero_datos_a_Analizar - 1].Fecha := StrToDate(linealeida);
// TTipoMedicion = (Diastolica, Sistolica);
end;
end;
end;
end.
el problema es que si cierro el archivo en esta unidad al final se soluciona el problema de entrada y saldia de datos pero si agrego mas datos y quiero hacer las operaciones no tiene en cuetna los datos nuevos