Mysterious Directory in DOS - Part II

Posted on 1998-10-14
Last Modified: 2012-06-21

The question I pose is more DOS than Pascal related but as there is no explicit DOS section I guess here might be the best place to ask it (hope that's ok). I did already pose it somewhere else a few months ago but as I was new to Experts Exchange I made a mistake by accepting an answer too soon which was incomplete (-:

There is a chess program for DOS named "Rebel" (version is 7.0). This chess program was able to create a directory in my DOS/Win 3.1 file system named "Ax nf zz"!!!
As I know it's not allowed in DOS/Win 3.1 to create a directory whose name contains spaces. If I try i.e. to do it by typing "MKDIR C:\Ay dd" I get an error message like "too many parameters ...dd".

I have two questions now:

1. How is it possible to create such an "illegal" directory in a DOS/Win 3.x file system?

2. How can I access such a directory THROUGH DOS ("CD Ax nf zz" does not work!)?

Wizard needed!

Question by:StMeyer
  • 3
  • 2

Accepted Solution

scrapdog earned 100 total points
ID: 1215792
The only reason you cannot create or change to a directory from the dos command line is because of the way dos commands handle parameters.  To dos commands, the separator between parameters is a space.  It thinks you are entering several parameters instead of one.  However, it is LEGAL, and it is POSSIBLE to create a directory with spaces.

To do this programmatically in Pascal, you just use the MkDir command.  This is a string enlcosed within quotes, so spaces are taken literally.  The following program will create a directory named ax nf zz:

program md2;

uses dos;

   s :string;

 s := 'ax nf zz';

You can access the directory programmatically using the ChDir command.  The cd command from the command line won't work, however.  Here is a modified version of the cd command that you can use to access directories with spaces, from the command line:

program cd2;

uses dos;

   s :string;
   i :integer;

 for i := 1 to ParamCount do s := s + ParamStr(i) + ' ';
 s[0] := chr(length(s)-1);

Compile this to disk.

To use this from the dos command line, for the directory ax nf zz, you would type:

cd2 ax nf zz

and then you will be transferred to the ax nf zz directory.  The cd2 command works like the cd command, except that if spaces are found, they are treated as separate parameters.  If there is more than one parameter, the program concatenates them to form one directory, with the spaces included.  However, this will not work with 2 or more spaces in a row, as any extra spaces are ignored.  For example, if you typed

cd2 ax     nf zz

this would still take you to the ax nf zz directory.

If you do not have a pascal compiler to compile this, I would be happy to send you the .exe version of this command if you leave me your e-mail address.


Author Comment

ID: 1215793
Hi scrapdog,

thank you very much for your answer - very good!

'Code begins
MKDIR "ax" + " " + "nf" + " " + "zz"
CHDIR "ax" + " " + "nf" + " " + "zz"
SHELL 'control where we are now
'Code ends

What's this??? - you may ask. Well, the first line is program md2 but not for Pascal, it' s for - ehm - (ok I must say it now even though I did not want to) Quick Basic. Thanks to you I was able to find out this form which can not be found in any handbook. The second line is a first step to rewrite program cd2 to Basic but I think ParamCount (I guess it returns the number of command line parameters - right?) has no equivalent in Basic. In case you are a Basic Wizard, too, please give me a hint (or do you know if I can put Pascal code - like Assembly - into Basic somehow?).
Don't worry! I intend to give you the points anyway, as you deserve them for your help. I' m just curious if you know some Basic (I still like it even though I know Pascal is more powerful). Unfortunately I don't have time to rewrite this into Pascal or any other language (one of my first programs):

By the way, there's a trick I use in my program for Windows 95 - DOS 7.0 (I guess): CD ax nf zz - does not work
                   CD "ax nf zz" - works!
Did you know this?

Best regards


P.S.: I can compile your code. Nevertheless thank you very much for the friendly offer to do it for me. Hope to hear from you once again soon.

Expert Comment

ID: 1215794
The last experience I had with BASIC (other than a little bit of Visual Basic) was the BASIC V2 found in the ROM of a Commodore 64.  In other words, I know bare bones ANSI (or even less) BASIC.

As far as your question about an equivalent to paramcount in BASIC, my guess would be no.  Unless your interpreter compiles your BASIC programs into .exe files or .com files, you can't call them on the command line, so there would be no way to include parameters.  Then again, I could be wrong.  In my experience, all BASIC was interpreted, rather than compiled.  However, if you use Visual Basic, there may be an equivalent to ParamCount, if you check the docs or help files for anything to do with command-line parameters.

Your question about Pascal code in BASIC is a definite no.  BASIC and Pascal are two very different languages.  Assembly language is not a part of Pascal, it is independent of Pascal, and I am pretty sure there are ways to incorporate assembly language routines into BASIC, but I don't think it is as easy as including it inline like you can in Pascal.  And I am not sure how you would do it.

As for cd "ax nf zz", I did not know that, because I have never come across a directory with spaces.  But I suppose this would be the first logical choice to try out if I ever had encountered one.

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 1215795
Thank you scrapdog! I'm quite optimistic now I can find the last step to debug my QBasic program.

Best regards


Expert Comment

ID: 1215796

I have a different solution to your problem. In my opinion, your
directory is (or could be) not a name including spaces at all, but the ASCII character 255. This character is blank, and yet it is valid for the MD, CD and RD commands, and acts as a regular name like all others. You can type this character onto the prompt (and in your pascal programs) by pressing Alt, clicking the ASCII character you want (i.e. 255) and release Alt. Again:
You will not see this character, but trust me: It is no blank !
(By the way, ASCII for blank is 32).


Author Comment

ID: 1215797
Hi Wolfman,

thank you for sharing your idea! If I open a DOS box in Win95 and type

CD "c:\ax nf zz"

using two spaces I can access the directory created by the chess program Rebel. If I do the same (no matter if with "" or without it) while using ASCII character 255 I get an error message ("invalid directory"). I mean this shows that the directory name (in that case) in fact includes spaces.
However, it's interesting to know that there's theoretically another possible explanation, so I'm glad you added the comment.

Thanks again and best regards


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.Net code to pascal 1 401
How to Use TTouchKeyboard inherit 1 1,505
How to use WebDispatcher to retrieve data 3 404
Delphi: how to implement a User Shortcut mapper? 1 138
Read the original post on Monitis Blog. Believe it or not, the most important thing about the website of your business is not what’s on it but how fast it loads. Yes, that’s right!    As you can see on this infographic (an oldie but goodie!), …
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question