Delphi and Kylix

Moderators: pritaeas
Number of threads: 7244
Number of posts: 19051

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Another problem with my random or serial files Posted by deanobajio on 14 Jul 2002 at 11:22 AM
Hi,
Im trying to create either a random or a serial access file (either will do) but after writing the code and it being compiled no problem, the program will create the file but will not enter the information into the file.

My serial file code is written below:
--
unit main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
bttn_create: TButton;
bttn_exit: TButton;
procedure bttn_createClick(Sender: TObject);
procedure bttn_exitClick(Sender: TObject);
end;

wrestler_type = record
wrestler_number :integer;
stage_name :string[30];
card_status :integer;
belt_status :string[1];
end;



var
Form1: TForm1;
wrestler_file :file of wrestler_type;
wrestler_rec :wrestler_type;
count :integer;

implementation
{$R *.dfm}

procedure create_file;
begin
assign(wrestler_file, 'wrestlers.dat');
rewrite(wrestler_file);
count := 1;
repeat
wrestler_rec.wrestler_number := count;
wrestler_rec.stage_name := 'Empty';
wrestler_rec.card_status := 1;
wrestler_rec.belt_status := 'N';
count := count + 1;
until count = 99;
reset(wrestler_file);
close(wrestler_file);
end;


procedure TForm1.bttn_createClick(Sender: TObject);
begin
create_file;
end;

procedure TForm1.bttn_exitClick(Sender: TObject);
begin
close;
end;

end.
--
The file "wrestlers.dat" is created but with none of the information inputted.

This problem is really starting to annoy me now, lol, so any help you can give me would be appreciated.

Thanks,
Deanobajio

p.s I'm upgrading from TP7 which is probably the reason I can't see the problem :o)
Report
Re: Another problem with my random or serial files Posted by zibadian on 14 Jul 2002 at 1:38 PM
: Hi,
: Im trying to create either a random or a serial access file (either will do) but after writing the code and it being compiled no problem, the program will create the file but will not enter the information into the file.
:
: My serial file code is written below:
: --
: unit main;
:
: interface
:
: uses
: Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
: Dialogs, StdCtrls;
:
: type
: TForm1 = class(TForm)
: bttn_create: TButton;
: bttn_exit: TButton;
: procedure bttn_createClick(Sender: TObject);
: procedure bttn_exitClick(Sender: TObject);
: end;
:
: wrestler_type = record
: wrestler_number :integer;
: stage_name :string[30];
: card_status :integer;
: belt_status :string[1];
: end;
:
:
:
: var
: Form1: TForm1;
: wrestler_file :file of wrestler_type;
: wrestler_rec :wrestler_type;
: count :integer;
:
: implementation
: {$R *.dfm}
:
: procedure create_file;
: begin
: assign(wrestler_file, 'wrestlers.dat');
: rewrite(wrestler_file);
: count := 1;
: repeat
: wrestler_rec.wrestler_number := count;
: wrestler_rec.stage_name := 'Empty';
: wrestler_rec.card_status := 1;
: wrestler_rec.belt_status := 'N';
: count := count + 1;
: until count = 99;
: reset(wrestler_file);
: close(wrestler_file);
: end;
:
:
: procedure TForm1.bttn_createClick(Sender: TObject);
: begin
: create_file;
: end;
:
: procedure TForm1.bttn_exitClick(Sender: TObject);
: begin
: close;
: end;
:
: end.
: --
: The file "wrestlers.dat" is created but with none of the information inputted.
:
: This problem is really starting to annoy me now, lol, so any help you can give me would be appreciated.
:
: Thanks,
: Deanobajio
:
: p.s I'm upgrading from TP7 which is probably the reason I can't see the problem :o)
:
The problem is that you don't write the data anywhere into the file. You need to add the following line somewhere in your procedure:
  write(wrestler_file, wrestler_rec);

Report
Re: Another problem with my random or serial files Posted by deanobajio on 14 Jul 2002 at 3:41 PM
Thanks for that, having one of those 'duh!' moments now :o)

Thanks,
Deanobajio




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.