Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

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

Report
output and input to/from disk. Turbo 4 book not simple enough Posted by front1sdog on 12 Jan 2011 at 1:56 PM
Hello Pascal
I've spent the last week,as time allows,trying not to bother
you good people with this. I assume it's an easy question for
experienced people.
What I have compiles and,when run,gives me DOS error 5 - file
access denieghd. (file not open for writting). What I have seems
to folow what my turbo 4 book says(I'm writing in free Pascal)
but won't run.
I'm trying to (eventually) save a list of arrays to disk from
one p'gram and read then with another p'gram.
Turbo seems to imply that this works only with records but I've tried it without. Same difference.
Pertinent parts:

type
box_array = array[0..256]of array[0..2] of smallint;


can = record
carton : box_array;
end;
{************}
var
i,j : smallint;
box : box_array;
canis : can;
canister : file of can;

{**************}

assign(canister,'e:');
reset(canister);
write(canister,canis);
close(canister);
writeln('all on disk');
readln;


assign(canister,'e:');
reset(canister);
read(canister,canis);
close(canister);
writeln('all on disk');
readln;

I assume this is some obvious mistake that I can't get from
my turbo 4 book.
Appreciate any help.
Front one's






Report
Re: output and input to/from disk. Turbo 4 book not simple enough Posted by quikcarl on 12 Jan 2011 at 2:57 PM
It is some simple misteaks that you've made. When assigning a file to disk, you need to have a name not just a disk drive and a path. Plus if you're writing a file, it needs to be rewrite instead of reset.

: assign(canister,'e:');
: reset(canister);
: write(canister,canis);
: close(canister);
: writeln('all on disk');
: readln;

  assign( canister, 'e:\quikcarl.int' );
  rewrite( canister );
  write( canister, canis );
  close( canister );
  writeln( 'all on disk' );
  readln;

Report
Re: output and input to/from disk. Turbo 4 book not simple enough Posted by front1sdog on 12 Jan 2011 at 10:19 PM
Quick indeed.
Thank you very much. I'll try the fix as soon as I can get to it.
I don't doubt that your right but if something has more than two parts I'm likly to get things mixed up. Hope you don't hear from me soon.
Front One's
It's later,It's more.
Demo now works perfectly. Turbo 4 book seems to impley
that typed/untyped file elements must be records. found the
procedure works fine with just the array.
I'll go find more stuff for you guys.
Front one's again.
Report
Re: output and input to/from disk. Turbo 4 book not simple enough Posted by _Atex_ on 21 Jan 2011 at 9:51 PM
: Turbo 4 book seems to impley
: that typed/untyped file elements must be records. found the
: procedure works fine with just the array.
:

Forget the Turbo 4 book, is very outdated this days, almost 25 yr old. FP has really good documentation, read that instead.

Report
Re: output and input to/from disk. Turbo 4 book not simple enough Posted by front1sdog on 22 Jan 2011 at 3:53 PM
Hello ATEX
Thanks for the tip. I'll try to find FP documents and look them over.
As I progress,I'm generating a lot of small trial and demo p'grams.
They're really basic noob stuff (as you can tell from my questions) But I've gone all the way back to the begining of time several times (oct 09) and didn't find anything in place that helped me.
I don't think anyone's ever going to ask a question that I can answer with any confidence. Is it resonable to have this sort of "un-question" in the stack - just to have it on record?
A reminder : Play is the only true learning behavior. I'm never desperate for a response.
Front one's



 

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.