Batch parameter limit in MS-DOS 6.21?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Clueless in Seattle
Posts: 47
Joined: 01 Jul 2011 13:37

Batch parameter limit in MS-DOS 6.21?

#1 Post by Clueless in Seattle » 11 Nov 2013 11:29

Hi again!

After a long hiatus due to chronic illness I'm trying to pick-up a batch file project where I left off some time ago, and I'm afraid I'm pretty rusty and have forgotten most of what little I knew about batch file programming.

I'm still running MS-DOS 6.21 (Not under Windows in a DOS box, but plain MS-DOS like we used to run it back in the 90s (Ah! Those were the days!) but I digress... :wink: )

I've got a DOS text editor called TSE 2.5 that has a built in macro language which allows me to run batch files from within the editor and pass variables from the text editor to the batch file as parameters.

I ran into a problem with this process this morning:

I was working on a TSE macro that would pass a bunch of path strings to a DOS batch file as parameters.

It worked OK for the first 4 path strings, but when it came to the 5th parameter (another long path string) it only passed on the first 15 characters of the path string to the batch file.

So, it seems I've run up against some kind of limit and I'm trying to figure out what it is and how to increase it. I figure it might be in the text editor itself, in MS-DOS, or in the batch file process within MS-DOS.

I'd be grateful for some help troubleshooting this problem, because I've got at least a couple, probably more, long path strings that I need to pass to the batch file.

Anyone here still remember how to configure MS-DOS?

Any ideas?

Will in Seattle
a.k.a. "Clueless

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch parameter limit in MS-DOS 6.21?

#2 Post by foxidrive » 11 Nov 2013 15:40

It may be a character in the string that is causing the issue, like = or ;

Can you explain what you were passing?

Aacini
Expert
Posts: 1932
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Batch parameter limit in MS-DOS 6.21?

#3 Post by Aacini » 11 Nov 2013 17:15

Clueless in Seattle wrote:Hi again!

I'm still running MS-DOS 6.21 (Not under Windows in a DOS box, but plain MS-DOS like we used to run it back in the 90s (Ah! Those were the days!) but I digress... :wink: )

Will in Seattle
a.k.a. "Clueless


I agree! :D

If my knowledge of "old" DOS is right, the command line parameters are limited to 127 characters (the half of the PSP), and there is no way to avoid it!

Antonio

Clueless in Seattle
Posts: 47
Joined: 01 Jul 2011 13:37

Re: Batch parameter limit in MS-DOS 6.21?

#4 Post by Clueless in Seattle » 12 Nov 2013 10:14

foxidrive wrote:It may be a character in the string that is causing the issue, like = or ;

Can you explain what you were passing?


Yup!

Here are parameters 1 and 5:

1. C:\WP\TSE2012\MYMACROS\ENCR-E2D.ARC\STRINGS.S
5. D:\WP\TSE2012\MYMACROS\ENCR-E2D.ARC\STRINGS.PGP


Parameter 5 was the one that got truncated in the batch file.

I tried an experiment in which I deleted parameters 2, 3 & 4 from the text editor macro, so that instead of trying to pass 5 parameters from the text editor macro to my batch file, it only had to try to pass 2 parameters (the second one being the the original #5 that had been truncated when I tried to pass all five).

When I reduced the number of parameters from 5 to 2, both parameters passed correctly to my batch file.

So, it seems I've come up against some kind of parameter limit. I counted the total number of characters in the original set of 5 parameters and got 135.

When I first attempted to pass all five parameters from the text editor macro to my batch file, the 5th parameter ended up truncated to D:\WP\TSE2012\MYM. So it looks like about 30 characters got trimmed from the tail end of that last parameter.

Subtracting 30 from 135 leaves me 105. So it looks like I've got to work within an upper parameter character limit of about 100 characters.

For now I think I'll try breaking down my batch file into discrete modules, each in its own batch file, to be called in sequence from the text editor. That way I can probably figure out a way to reduce the number of parameters I need to pass to any given module.

I can also use the D: OR E: and CD DOS commands to log into one or the other of the sub-directories, thus significantly shortening either the source or target parameters to just a filename plus extension.

But, I'm still curious to know the nature of the limit I seem to have run up against and if or how it might be increased (I've already tried doubling the environment in my config.sys, to no avail).

Will in Seattle
a.k.a. "Clueless"

Aacini
Expert
Posts: 1932
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Batch parameter limit in MS-DOS 6.21?

#5 Post by Aacini » 12 Nov 2013 10:55

Clueless in Seattle wrote:. . .
But, I'm still curious to know the nature of the limit I seem to have run up against and if or how it might be increased (I've already tried doubling the environment in my config.sys, to no avail).

Will in Seattle
a.k.a. "Clueless"


Didn't you see my answer above? :?

When .com and .exe executables are loaded, there is an area of 256 bytes that is created immediately before the executable code called Program Segment Prefix that in its first 128 bytes store several information (like the FCB of two files given as parameters and vector addresses to restore when the program ends). In the last 128 bytes is stored a count byte, followed by the parameters of the command that ends in the CR character, so the maximum lenght of the parameters should be 126 characters.

Antonio

Clueless in Seattle
Posts: 47
Joined: 01 Jul 2011 13:37

Re: Batch parameter limit in MS-DOS 6.21?

#6 Post by Clueless in Seattle » 12 Nov 2013 11:45

Aacini wrote:
Clueless in Seattle wrote:. . .
But, I'm still curious to know the nature of the limit I seem to have run up against and if or how it might be increased (I've already tried doubling the environment in my config.sys, to no avail).

Will in Seattle
a.k.a. "Clueless"


Didn't you see my answer above? :?

When .com and .exe executables are loaded, there is an area of 256 bytes that is created immediately before the executable code called Program Segment Prefix that in its first 128 bytes store several information (like the FCB of two files given as parameters and vector addresses to restore when the program ends). In the last 128 bytes is stored a count byte, followed by the parameters of the command that ends in the CR character, so the maximum lenght of the parameters should be 126 characters.

Antonio


I'm sorry, Antonio. Yes, I did read your message, but I have to confess that due to my worsening cognitive impairment I didn't grasp what you were telling me.

Just now I went back and re-read it:

...the command line parameters are limited to 127 characters (the half of the PSP), and there is no way to avoid it!


I'm afraid that on my first reading I mistook you to be saying that path strings are limited to 127 characters.

So, yes, you've answered my question, and I'm grateful to you for that. Thanks!

I hope you'll try to be patient with me. I'm severely limited by chronic illness symptoms and the side-effects of the drugs I need to take for them, so I'm not as sharp as I used to be. And I'm only able to sit up at the PC for a few minutes at a time and then need to go back to bed to rest. So I often lose my train of thought in between sessions.

Thanks again for answering my question. You've given me the information I needed,

Will in Seattle
a.k.a. "Clueless"

Clueless in Seattle
Posts: 47
Joined: 01 Jul 2011 13:37

Re: Batch parameter limit in MS-DOS 6.21?

#7 Post by Clueless in Seattle » 12 Nov 2013 14:32

Aacini wrote:If my knowledge of "old" DOS is right, the command line parameters are limited to 127 characters (the half of the PSP), and there is no way to avoid it!


OK, now that I know that my batch file parameter limit is 127 characters, I'm trying to account for what seem to be some missing "ghost" characters.

To help figure out where they might be I've redirected into a text file the parameters passed to my batch file:

    Parameter 0: = encr-e2d
    Parameter 1: = C:\WP\TSE2012\MYMACROS\ENCR-E2D.ARC\STRINGS.S
    Parameter 2: = STRINGS
    Parameter 3: = .S
    Parameter 4: = \WP\TSE2012\MYMACROS\ENCR-E2D.ARC\
    Parameter 5: = D:\WP\TSE2012\MYM


When I count up the characters I get a total of 113, not 127.

Doesn't that leave 14 characters unaccounted for?

Do the spaces in the command line count? If so then we can subtract 5 spaces, can't we?

which leaves 9 characters.

Could 8 of those 9 characters be accounted for by the name of the batch file on the command line?

If so, then I'm still left with one mysterious "ghost" character, aren't I?

I'd be grateful for some help figuring out to calculate how many characters I can safely pass in parameters from my text editor macro to an MS-DOS batch file.

Will in Seattle
a.k.a. "Clueless"

Aacini
Expert
Posts: 1932
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Batch parameter limit in MS-DOS 6.21?

#8 Post by Aacini » 12 Nov 2013 15:27

Clueless in Seattle wrote:. . .

Do the spaces in the command line count? If so then we can subtract 5 spaces, can't we?

Could 8 of those 9 characters be accounted for by the name of the batch file on the command line?

If so, then I'm still left with one mysterious "ghost" character, aren't I?

. . .

Will in Seattle
a.k.a. "Clueless"


Yes, I think you are right: command.com read lines of 127 characters max, so the name of the Batch file itself is included in this count.

In the PSP the parameters are stored this way:

Code: Select all

# parameters...........<CR>_________________________     <- Block of 128 bytes
^                        ^- The Enter key
+- first byte indicate "parameters lenght"

As you can see, this format "eats" two bytes.

Antonio

Post Reply