[comp.os.msdos.programmer] Problem EXEC'ing from program

christopher@gacvx2.gac.edu (02/20/91)

The Program: (JPI Topspeed Modula-2, but NOT a Mod-2 question)
--------------------------
MODULE TestTed;
FROM Lib IMPORT Execute;
FROM IO IMPORT WrLn,WrCard,RdStr,WrStr;
FROM Storage IMPORT ALLOCATE,DEALLOCATE;

VAR ReturnVal:CARDINAL;

BEGIN
  ALLOCATE(MemBlock,4095);   (* size - paragraphs *)
  WrStr("Enter file name to open (blank for none): ");
  RdStr(CommandLineParms);
  ReturnVal:=Execute("TED.COM",CommandLineParms,MemBlock,65520); (*size-bytes*)
  WrCard(ReturnVal,6); WrLn;
  DEALLOCATE(MemBlock,4095);  (* size - paragraphs *)
END TestTed.
--------------------------

The Situation:
  The program seems fairly self-explanatory, even if your not a Modula-2
person (and I'm not, either).  Basically, I'm trying to EXEC a program
(TED.COM) from within this TESTTED.EXE program.  The MemBlock is a block of
memory in which to execute the program.  The TED.COM program is PCMagazine's
TinyEDitor.  It takes an optional filename as a parameter, else starts a new
file.

What Happens (ie The Problems):
  When I don't type in a string (CommandLineParms), the program runs fine and
starts a new file, I can save it when I'm done, and I get back to this 
program and the return value from the Execute call (which is the DOS return
value) is 0.
  When I type in a bogus/non-existent file name, TED starts a new file just
like it does from the plain command line, and the return value is again 0.
  BUT, when I give it the name of an existing file, the program locks up the
computer.  I mean, it's time to head for the Big Red Switch.  This is not
what TED does from the command line (it loads the file as it should).

What it could be:
  - DOS is not (for the most part) re-entrant, so trying to open the file
    with a DOS INT 21 call chokes the machine.  I don't think it is this.
    For instance, the program has no trouble determining that a bogus filename
    is non-existent (probably via a DOS INT call).
  - An EXEC'd program needs to be an EXE file, and not a COM.  Well, I tried
    recompiling the ASM source to TED with Turbo Assembler, and linking, but
    then the TED.EXE wouldn't load an existing file when tested from the
    command line (always started a new file or something).  Now, I'm not an 
    assembly language programmer, but there would seem to be something in
    TED that doesn't work when it's and EXE (recompiled and linked to COM
    worked fine).  BUT, if it were the EXE/COM program requirement for EXEC,
    then why does the program (TED.COM, and TESTTED.EXE) run fine when no
    command line is passed to the EXEC'd program?  This wouldn't seem to be
    "it" either.
  - A problem with JPI Modula-2 compiler/system.  This would be harder to 
    track down.  My suspicion is that it is not this, but is related to DOS.

  - OR, ????????

The Setting:
  I have run the program in two settings:
   IBM PS/2 Model 50Z, running DOS 4.0 (reported by VER), 1MB mem

   IBM PS/2 Model 25, running DOS 3.3 (reported by VER), and on a network
    running Novell Netware 4.3 (or something like that)
   
   These are both True Blue machines, not clones, so compatibility should not
   be an issue (he says smiling).


All suggestions and thoughts heartily appreciated,

Chris Kane
christopher@gacvx1.bitnet
christopher@gacvx2.gac.edu
kane@nic.gac.edu

Gustavus Adolphus College,    St. Peter, Minnesota