Morning Charlie,

On 21/03/2021 09:23, Karoly Balogh via fpc-pascal wrote:
...It was on my ToDo to get back to it, but actually, I
prefer indeed if the QL community sends patches...
Ok, no worries. I can "svn diff" if that's what you would prefer? Where should I send them, when I'm ready please?


I was just not going to
the QL forum lately, there's always one too many retro platforms to care
for. :| Sorry about it!
No problem.


What are you trying to do here? This isn't valid Pascal file handling
code. ....

Yes, I know. Sorry, I could have explained better. This is the file I was testing:

{ Program to demonstrate the Erase function. }

Var F : Text;

begin
  Assign(F,'ram1_test.txt');
  Rewrite(F);
  Writeln('The file, "ram1_test.txt" will be deleted.');
  Writeln(F,'Try and find this when I''m finished !');
  Close(F);
  Erase(F);
end.

In the end, the only way I could get it to actually delete the test file, on device ram1_, was:

Var F : Text;

begin
  Assign(F,'ram1_test.txt');
  Writeln('The file, "ram1_test.txt" will be deleted.');
  Erase(F);
end.


The RTL on init will open stdin/stdout for you on start, so simple I/O
works on the console, so your writeln() will succeed, regardless of you
trying to reopen the console afterwards.

Hmm. I wasn't trying to reopen the console, the line in the test program that barfed was this one:

  Writeln(F,'Try and find this when I''m finished !');

I have a minimum test harness for it at the moment that I'm attempting to sort out.

Var F : Text;

begin
  Assign(F,'ram1_test.txt');
  Rewrite(F);
  Writeln(F,'Try and find this when I''m finished !');
  Close(F);
end.

I've tested with just the assign and rewrite, seems to have had no effect - the output file, which has some text in it, remained untouched. Adding in the writeln call causes runtime error 103. Which I believe is "file not open".

Write()/Writeln() and WriteStr() are special functions, which the compiler
handles directly, and breaks them down into a series of individual calls,
depending on the type of the parameters in the parameter list printed.

Understood, thanks.

you probably don't need to touch that code anyway, as everything just
calls do_write() in the end, which is in rtl/sinclairql/sysfile.inc.

Thanks, that's where I'll start looking for problems.


If you know m68k assembly, You can easily identify which functions are
called directly, if you generate assembly code with the -al parameter,
while compiling.

Excellent, I'm reasonably au-fait with M68K assembly. (Famous last words!)

Then you can check directly what the compiler does with
your code, and which functions it calls (even if name mangling obscures
them a bit, but it's still possible to understand better what is going on
then). But as I said, you won't need to touch any of these.

The Reset() function's implementation is in rtl/inc/file.inc, along with
Rewrite(). But you most likely don't have to touch these either, because
they internally wrap to do_open(), which is in rtl/sinclairql/sysfile.inc.

Ok, I'll have a look at those as well, just in case.

This might need to be extended to handle various file open modes (read,
write, overwrite, append, etc) better. Also, integrating console handling
in there might have its own quirks.

Probably not. The QL treats the console as a text file and pretty much anything goes, tabs, positioning etc.

... This code is in rtl/inc/. And it wraps to system-specific
functions internally, which are already in the sinclairql RTL, just mostly
weren't implemented. Basically any do_<something>() functions which you
see in there.

Aha! Just what I was looking for. I knew this stuff had to be system specific.

...


Many thanks indeed, I'll see what I can come up with.


Cheers,
Norm.

--
Norman Dunbar
Dunbar IT Consultants Ltd

Registered address:
27a Lidget Hill
Pudsey
West Yorkshire
United Kingdom
LS28 7LG

Company Number: 05132767
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to