Jump to content

First DOS tool in new programming language

Kaj de Vos

Recommended Posts

Previous demo here


It's the first anniversary of my language project. To celebrate, here is the first tool written in it:





It's an alternative for the ?DIR command in SpartaDOS and RealDOS, the pwd command on Unix systems, and the cd command (without parameter) in MS-DOS/Windows.


An amazing amount of design and research went into this tiny and seemingly trivial program. It will be a template for future programs. Here are just some of the issues with making it cross-platform:




For reference, here is the very same program compiled for my 64-bit Linux development system:




Thanks go to the people here for their advice, especially @sanny, who helped get it to work, and extended CC65.


It's probably most comfortable to rename the Atari version to WHERE.COM for SpartaDOS and RealDOS. The Linux version needs to be made executable as per usual:

chmod +x where

On command-line systems, a few command-line options are available:

where help

where about

where version


./where help

Without parameters, on command-line systems, the program will just print the current working folder and return to the command-line. On Atari systems with a menu-based DOS, it will ask for a key press before returning, to give you the chance to read the output before the menu clears the screen.


The program is really only useful on SpartaDOS version 3 and up and on RealDOS, possibly also on SpartaDOS 2. On other DOS'es, including SpartaDOS 1, it cannot get the current working folder. It will report > (the root folder in SpartaDOS format) which is correct for DOS'es that don't support sub-directories. On MyDOS, it will report "D:" which is not very useful, but not incorrect, because it denotes the current drive and working folder.

where help

gets formatted for 40-columns display. If you have an 80-colums driver that properly sets RMARGN, and on Linux, the output is formatted for 80-columns display.


(Do wide-display drivers set RMARGN? The wide display mode in Altirra does not, so it doesn't get the wide formatting.)


Any error messages are also formatted for 40-columns and 80-colums displays accordingly.


Test reports are welcome, especially for SpartaDOS 2, RealDOS, and 80-colums drivers.

Edited by Kaj de Vos
Still don't want D: replaced with smileys
  • Thanks 1
Link to comment
Share on other sites

42 minutes ago, Kaj de Vos said:

Is there any change in SDX in the XIO command for getting the working folder, compared to SpartaDOS 3?

To be honest, I do not know - my first SpartaDOS years back then was SpartaDOS X and so it remains until this day. The CIO is not often used in SDX utilities, so I just checked, if XIO 48 works as advertised in the SDX User's Manual, section 6.3.18. But it seems so:




The program:



  • Thanks 1
Link to comment
Share on other sites

5 minutes ago, Kaj de Vos said:

I will have to see if the problem is in my code or in CC65.

After the recent, much revealing discussion on the left margin issue in CC65 libs, I would not be much surprised if it was the latter.


6 minutes ago, Kaj de Vos said:

Does SDX still take the original > SpartaDOS path separator?

Yes, "\" and ">" are equivalent as path separators in SDX.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

If you use `open()` CC65 does prepend Dn: to the file name.


Edit: I see. You are talking about `getcwd()`, aren't you? Yes, there is no such thing. SpartaDOS should use the current drive.

Edited by sanny
Link to comment
Share on other sites

18 minutes ago, Kaj de Vos said:

Yes, on SDX, not on previous SpartaDOS.

I know, I am just saying that it is no matter that the manual says "Dx:", because this does not forbid using "D:" anyways. Of course SD 3 (maybe except 3.2g) has no concept of current drive IIRC, so what is "current" must be established by other means.

Edited by drac030
Link to comment
Share on other sites

SpartaDOS 3 has no current drive, at least not denoted for the outer world by "D:", but it does have a current folder on each drive.


More anomalies. When the XIO call is made to work, CC65 returns proper paths for SpartaDOS 3, but when SpartaDOS X is in a root, getcwd () returns an empty string, which is not standards-compliant. The SDX command line behaves the same. The XIO interface changed behaviour quite a bit.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...