[comp.sys.ibm.pc] Expanding Environment on a Z-158

kwf@ece-csc.UUCP (Kenneth W. Fernald) (07/08/88)

I have a Zenith 158 running MS-DOS 3.1 (supplied by Zenith).  Does anyone
know how to expand the available environment space.  I've tried using
the setenv program from Microsoft, but it reports an unrecognizable
command.com.

Please reply by e-mail to kwf@uxv.larc.nasa.gov

thanks in advance.

kwf@ece-csc.UUCP (Kenneth W. Fernald) (07/11/88)

I sent a message a few days ago that read as follows:

>I have a Zenith 158 running MS-DOS 3.1 (supplied by Zenith).  Does anyone
>know how to expand the available environment space.  I've tried using
>the setenv program from Microsoft, but it reports an unrecognizable
>command.com.

>Please reply by e-mail to kwf@uxv.larc.nasa.gov

>thanks in advance.

I have received several suggestions, all of which recommend using
the /E:XXX option of the COMMAND.COM (using the SHELL= command).
Although I am grateful for those individual's interest and help, I failed
to mention in my original question that my Zenith version of MS-DOS 3.1
doesn't appear to support the /E option.  It is not documented, and when I
attempt to use it, no apparent change in environment size occurs.

Again, if anyone has any ideas, I'd be grateful for any addition help.

thanks again.

madd@bu-cs.BU.EDU (Jim Frost) (07/12/88)

In article <3705@ece-csc.UUCP> kwf@ece-csc.UUCP (Kenneth W. Fernald) writes:
|I have received several suggestions, all of which recommend using
|the /E:XXX option of the COMMAND.COM (using the SHELL= command).
|Although I am grateful for those individual's interest and help, I failed
|to mention in my original question that my Zenith version of MS-DOS 3.1
|doesn't appear to support the /E option.  It is not documented, and when I
|attempt to use it, no apparent change in environment size occurs.

Zenith's isn't the only version with this problem.  Our true-blue
version of PC-DOS 3.10 refuses to believe the /e option.  Mostly I've
gotten around this by using my own shell, but there are many cases
where that just isn't a good idea.

How can you fix it?  One easy way to do it (at the cost of some
memory) would be to run a small program which sets environment
variables for itself and then runs command.com.  For example:

{ envmake.pas:

  this is a Turbo Pascal 4.0 program that is supposed to set up an
  environment before calling command.com to allow for large
  environments.  it has not been tested but it should give you an
  idea.  this program is in the public domain.

  written by jim frost on 7.11.88.  comments to madd@bu-it.bu.edu
}

{$m 1024,0,0 }
program envmake;

const prog = 'envmake';
      fname = '\envmake.def';
      elen = 1023;

type str = string[255];

var env  : array[0..1024] of char; { environment area }
    ptr  : integer;                { ptr in environment area }
    eseg,                          { segment addr of environment }
    eofs : word;                   { offset addr of environment }
    f    : text;                   { file to get defs from }

{ add to the environment buffer }

procedure addenv(s : str);
var eq : boolean;
    a  : integer;
begin
  if ptr+length(s)+2 > elen then begin
    writeln(prog,': environment area full');
    exit
  end;
  eq:= false;
  for a:= 1 to length(s) do begin
    if s[a] = '=' then
      eq:= true;
    if not eq then                  { capitalize up to '=' }
      env[ptr]:= upcase(s[a]);
    else
      env[ptr]:= s[a];
    inc(ptr)
  end;
  env[ptr]:= #0;                    { terminate string }
  inc(ptr);
  env[ptr]:= #0                     { terminate environment }
end;

begin
  eseg:= seg(env)+(ofs(env) mod 16);
  eofs:= ofs(env) mod 16;
  if eofs <> 0 then begin     { adjust into buffer for paragraph alignment }
    inc(eseg);
    ptr:= 16 - eofs
  end;
  memw[prefixseg:$2c]:= eseg; { tell dos about it }

  { environment is now at env[ptr], so fill it }

  assign(f,fname);
  reset(f);
  if ioresult <> 0 then
    writeln(prgname,': could not open ',fname)
  else begin
    while not eof(f) do begin
      readln(f,s);
      addenv(s)
    end;
    close(f)
  end;
  exec('\command.com','/p');
  writeln('exec: command.com execution failure (',doserror,')');
  repeat until false
end.

Put that in the shell= portion of config.sys.  I think it'll work, but
I don't have a compiler or machine to test it on.

Happy hacking,

jim frost
madd@bu-it.bu.edu

wfp@dasys1.UUCP (William Phillips) (07/14/88)

In article <3705@ece-csc.UUCP> kwf@ece-csc.UUCP (Kenneth W. Fernald) writes:

>I have received several suggestions, all of which recommend using
>the /E:XXX option of the COMMAND.COM (using the SHELL= command).
>Although I am grateful for those individual's interest and help, I failed
>to mention in my original question that my Zenith version of MS-DOS 3.1
>doesn't appear to support the /E option.  It is not documented, and when I
>attempt to use it, no apparent change in environment size occurs.

>Again, if anyone has any ideas, I'd be grateful for any addition help.


It's not documented in PC-DOS 3.1 either, but it works.  I had the same
problem on a generic clone a couple of days ago.  Pulled together a few
vague recollections and found an article in Programmer's Journal that
gave me half the answer.  Scratched head, came up with the following,
which works for me:

on the last line of CONFIG.SYS, I put

shell=c:\command.com /p/e:16

...for DOS 3.1, the number after e: is the number of 16-byte "paragraphs"
to allow for the environment (i.e., 256 bytes in my case).  In later
versions, for which the /e: option is documented, the number is the number
of _bytes_ to allow.

Hope this helps.

-- 
William Phillips                 {allegra,philabs,cmcl2}!phri\
Big Electric Cat Public Unix           {bellcore,cmcl2}!cucard!dasys1!wfp
New York, NY, USA                !!! JUST SAY "NO" TO OS/2 !!!