QL / PASCAL

Anything QL Software or Programming Related.
User avatar
NormanDunbar
Forum Moderator
Posts: 1500
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: QL / PASCAL

Postby NormanDunbar » Sun Apr 04, 2021 4:37 pm

Last one for today, I promise! ;)

I've resolved the problem with renaming a file on the QL:

  • If "oldfile" doesn't exist, Pascal barfs with runtime error 2 -- file not found.
  • If newfile already exists, Pascal barfs with runtime error 5 -- file access error (sorry, the best I can do!)
  • If oldfile there and newfile not, the file is renamed.

Unfortunately, I found another foible in SMSQ and deleteing a directory.

  • If directory not empty, runtime error 5 occurs. File access error. (Sorry, best I can do!)
  • If directory present, and empty of files, directory is deleted.
  • If directory is not present, no errors occur! We expect a runtime error 3 Path not found.

So, I set up a couple of assembly language tests and IO_DELET doesn't care if the file is found or not, it doesn't return ERR_NF from the trap, it returns 0 instead. Hmmm.

I tried to open the non-existent directory, ram1_xxxxxx, as a directory before attempting to delete it, and it worked! Checking with the Channels thing, it had opened RAM1_ as a directory instead. It appears that SMSQ/QPC will do this if the given full filename is not a directory, it opens the next level up until it comes across something that is a directory? Or so it would seem.

This means that the QL version of rmdir, under Pascal, is different from the Linux version. Trying to delete a directory that's not there is expected to give error 3. Does anyone care? ;)


Latest patch file attached below here.

FPC.patch.4.zip
(3.86 KiB) Downloaded 5 times


Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890
User avatar
pjw
Aurora
Posts: 808
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: QL / PASCAL

Postby pjw » Sun Apr 04, 2021 5:46 pm

I submitted FDEL (DELETE as a function) for inclusion in SMSQ/E v3.34 (I think). This returned error In Use if the file to be deleted was open (which was my main reason for doing it), but did not return Not Found if the file was missing, as the OS doesnt either.
I got an unofficial version of SMSQ/E in return. This version returned Not Found correctly. I think Marcel fixed it. However, when the official version was released, FDEL didnt work at all! It errored on everything. This was fixed by Wolfgang in a subsequent release, but then with my original version, ie no Not Found :(
I dont know where Marcel's version went, or what he had done to improve it. Test before delete, perhaps? or actually fixed the trap?
Personally, I dont find it mightily important. But of course, it would be better if it worked consistently - not least of all so as not to rub against anyone's OCDs ;)


Per
Be wary of large West-Coast corporations bearing gifts!
- Ancient Trojan proverb
User avatar
NormanDunbar
Forum Moderator
Posts: 1500
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: QL / PASCAL

Postby NormanDunbar » Sun Apr 04, 2021 6:48 pm

I tried some assembly code running directly and not from Pascal. Traced through the delete and it never came back with ERR_NF. :(

Sounds like you have similar findings.

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890
User avatar
mk79
Aurora
Posts: 910
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: QL / PASCAL

Postby mk79 » Mon Apr 05, 2021 9:38 pm

NormanDunbar wrote:So, I set up a couple of assembly language tests and IO_DELET doesn't care if the file is found or not, it doesn't return ERR_NF from the trap, it returns 0 instead. Hmmm.
Yes, that is by design. Not sure why.
I tried to open the non-existent directory, ram1_xxxxxx, as a directory before attempting to delete it, and it worked! Checking with the Channels thing, it had opened RAM1_ as a directory instead.It appears that SMSQ/QPC will do this if the given full filename is not a directory, it opens the next level up until it comes across something that is a directory? Or so it would seem.
That, too, is by design and many programs rely on it.
If you want to check if the filename exists use normal read-only open. You could then check the type and even error out if the thing you are deleting is not a directory in the case of rmdir ;)

Cheers, Marcel


User avatar
mk79
Aurora
Posts: 910
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: QL / PASCAL

Postby mk79 » Mon Apr 05, 2021 9:41 pm

NormanDunbar wrote:I tried some assembly code running directly and not from Pascal. Traced through the delete and it never came back with ERR_NF. :(

Code: Select all

dop_del
        moveq   #0,d2
        moveq   #0,d3
        assert  ddf.remove,-1
        st      d3
        jsr     ddf_drname(a4)           ; search for name
        bne.s   dop_nfok                 ; ... not found is OK
[...]
dop_nfok
        cmp.w   #err.fdnf,d0             ; not found
        bne.l   dop_exit
dop_ok
        moveq   #0,d0
        bra.l   dop_exit
Not sure what I did or did not with FDEL, too long ago.

Cheers, Marcel


User avatar
pjw
Aurora
Posts: 808
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: QL / PASCAL

Postby pjw » Mon Apr 05, 2021 10:21 pm

Unarguably intentional. Perhaps it was done to avoid a program halting unnecessarily for an unimportant "error". Job already done. Why make a fuss?


Per
Be wary of large West-Coast corporations bearing gifts!
- Ancient Trojan proverb
User avatar
NormanDunbar
Forum Moderator
Posts: 1500
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: QL / PASCAL

Postby NormanDunbar » Mon Apr 05, 2021 10:32 pm

That explains why err_nf is not happening then. I'll try the other checks at some point. I wan't to add in default directory handling too. At least, I think I do!

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890
User avatar
mk79
Aurora
Posts: 910
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: QL / PASCAL

Postby mk79 » Tue Apr 06, 2021 12:40 pm

NormanDunbar wrote:That explains why err_nf is not happening then. I'll try the other checks at some point. I wan't to add in default directory handling too. At least, I think I do!
If you do, please do it more like I do in the most current SMSQ/E, TK2: don't add a default directory if the filename starts with a valid drive identifier. I'm sick of files like "win1_system_win8_test" because my DATAD defaults to win1_system and win8_ wasn't available when the access has happened.

Cheers, Marcel


User avatar
NormanDunbar
Forum Moderator
Posts: 1500
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: QL / PASCAL

Postby NormanDunbar » Tue Apr 06, 2021 4:41 pm

Good point, thanks.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890
martyn_hill
Super Gold Card
Posts: 662
Joined: Sat Oct 25, 2014 9:53 am

Re: QL / PASCAL

Postby martyn_hill » Tue Apr 06, 2021 5:46 pm

Hi Marcel!

mk79 wrote:...don't add a default directory if the filename starts with a valid drive identifier. I'm sick of files like "win1_system_win8_test" because my DATAD defaults to win1_system and win8_ wasn't available when the access has happened.


[Short, off-topic question] On this point of detecting whether a valid directory-device has already been specified, what is the most robust/elegant way to validate this, given the ever-growing list of possible devices that a user may have installed? I guess QPAC has a way to build it's list of available devices for the 'File' Thing...



Who is online

Users browsing this forum: No registered users and 1 guest