Onjahyr schrieb:
Help-me. In Delphi no problem! In Lazarus no Save, no Open...

// AssignFile(f, Arq_T);
// Reset(f);
// and
// Write(f, Tarefa);

=======================================
CODE:
=======================================

unit unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls,
  Buttons, ExtCtrls, Spin;

type
   tBase = record
   QtReg : integer;
   PsReg : integer;
end;

type
   tTarefa = record
   NOrdem     : SmallInt;
   Titulo     : string;
   Pergunta   : string;
   Resp1      : string;
   Resp2      : string;
   Resp3      : string;
   Resp4      : string;
   Resp5      : string;
   Tipo       : SmallInt;
   Qtd_Resp   : SmallInt;
   Resp_Certa : integer;
end;

type

  { Tfrm_Principal }

  Tfrm_Principal = class(TForm)
    Bevel1: TBevel;
    bt_Salvar: TSpeedButton;
    Edit_Resp_5: TEdit;
    Edit_Pergunta: TEdit;
    Edit_Resp_1: TEdit;
    Edit_Resp_2: TEdit;
    Edit_Resp_3: TEdit;
    Edit_Resp_4: TEdit;
    bt_Abrir: TSpeedButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label_Resp_Certa: TLabel;
    OD: TOpenDialog;
    SD: TSaveDialog;
    SpinEdit1: TSpinEdit;
    SpinEdit2: TSpinEdit;
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure bt_AbrirClick(Sender: TObject);
    procedure bt_SalvarClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  frm_Principal  : Tfrm_Principal;
  Base             : tBase;
  Tarefa           : tTarefa;
  f                 : file of tTarefa;
  Arq_T            : TFileName;

implementation

{ Tfrm_Principal }

procedure Tfrm_Principal.FormClose(Sender: TObject;
  var CloseAction: TCloseAction);
begin
//  Closefile(f);    ??????

  CloseAction:=caFree;
end;

procedure Tfrm_Principal.FormCreate(Sender: TObject);
begin
  Base.QtReg:=1; {inicia quantidade de registro}
  Base.PsReg:=1; {define a posiƧao do registro como um}
end;

procedure Tfrm_Principal.FormPaint(Sender: TObject);
begin
  Application.ProcessMessages;
end;

procedure Tfrm_Principal.bt_AbrirClick(Sender: TObject);
begin
  if OpenDialog1.Execute then
    begin
      Arq_T:=ExpandFileName(OpenDialog1.FileName);

      AssignFile(f, Arq_T);

      rewrite(f);

      Caption:=Tarefa.Titulo;
where do you read the data ??
schoudnt be here something like
read(f,Tarefa); ??


      Edit_Pergunta.text:=Tarefa.Pergunta;
      Edit_Resp_1.text:=Tarefa.Resp1;
      Edit_Resp_2.text:=Tarefa.Resp2;
      Edit_Resp_3.text:=Tarefa.Resp3;
      Edit_Resp_4.text:=Tarefa.Resp4;
      Edit_Resp_5.text:=Tarefa.Resp5;
      SpinEdit1.Value:=Tarefa.Tipo;
      SpinEdit2.Value:=Tarefa.Qtd_Resp;
      Label_Resp_Certa.Caption:=IntToStr(Tarefa.Resp_Certa);
    end;
end;

procedure Tfrm_Principal.bt_SalvarClick(Sender: TObject);
var
  v  : string;
begin
  v:=''; // soh para inicializar

  if SaveDialog1.Execute then
    begin
      Arq_T:=ExpandFileName(SaveDialog1.FileName);

      AssignFile(f, Arq_T);

      Reset(f);
Tarefa.Titulo:=frm_Principal.Caption;
      Tarefa.Pergunta:=Edit_Pergunta.Text;
      Tarefa.Resp1:=Edit_Resp_1.Text;
      Tarefa.Resp2:=Edit_Resp_2.Text;
      Tarefa.Resp3:=Edit_Resp_3.Text;
      Tarefa.Resp4:=Edit_Resp_4.Text;
      Tarefa.Resp5:=Edit_Resp_5.Text;
      Tarefa.Tipo:=SpinEdit1.Value;
      Tarefa.Qtd_Resp:=SpinEdit2.Value;
      v:='1345';
      Tarefa.Resp_Certa:=StrToInt(v);
      Tarefa.NOrdem:=Base.QtReg;

      Base.QtReg:=Base.QtReg + 1;
      Base.PsReg:=Base.QtReg;

      Write(f, Tarefa);
    end;
end;

initialization
  {$I unit1.lrs}

end.

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives



_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to