How do you write a text file from a "type record" ?

type
   ExtStruc = record
     ExtName : String [30];
     ExtComment1 : String [60];
     ExtComment2 : String [60];
   end;
var
   ExtFile : Textfile;
   ExtRec  : ExtStruc;
begin
  AssignFile(ExtFile, 'd:\test\tst.txt');
  Rewrite(ExtFile);
 ExtRec.ExtName :=  'john doe';
  ExtRec.ExtComment1 := 'comment line 1 test';
  ExtRec.ExtComment2 := 'comment line 2 test';

{  the following writeln statement works, but is there
  a way to use the RECORD ExtRec instead? I get an error. :(}

 { WriteLn(ExtFile, ExtRec.ExtName, ExtRec.ExtComment1,                ExtRec.ExtComment2);}


  I tried the following line and i get an error.  I dont want to specify
  all the different fields like the above writeln statement, that would
  be terrible when you have a big record layout.

      WriteLn(ExtFile, ExtRec);  <---- i get an error


   CloseFile(ExtFile);
waipahuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

XANCommented:
you can use any common delimeters like TAB #09 to get one string from one record. why not? :)
0
abrooksCommented:
To perform the type of IO you want do not use the text file IO routine.  Instead use the BlockRead and BlockWrite routines.  Pay particular attention to Reset and ReWrite Statements along with the Block Read and Write statements.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rwilson032697Commented:
The trick is to change these definitions:

var
   ExtFile : Textfile;
   ExtRec  : ExtStruc;

to

var
  ExtRec  : ExtStruc;
  ExtFile : File of ExtStruc;

And then do this:

 Write(ExtFile, ExtRec);

The difference here is that the file created will be a binary one, rather than a text one...

Cheers,

Raymond.
 
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

abrooksCommented:
Randy! Randy! Randy! Get Down!
0
rwilson032697Commented:
Hmm...
0
waipahuAuthor Commented:
Thanks, is there anyway I could get it in
ascii? This file will be ftp to an HP unix machine
which will then be loaded unto a database.
I can't use binary. :(
0
rwilson032697Commented:
No, you will need to write out the fields of the records individually.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.