[comp.lang.pascal] Alien programs within TP5

pmk@cip-s08.informatik.rwth-aachen.de (Michael Keukert) (09/25/89)

In Article 1136 of comp.lang.pascal: Erik Liljencrantz writes:

> With this approach the exact path and extension has to be known (of course you
> don't have to hardcode the path...). The other way is to let the command
> interpreter do the work (that is what COMSPEC contains, normally COMMAND.COM):
>
>   Exec(GetEnv('COMSPEC'),'/C '+ProgramName);
>                           ^^
>                           Switch to COMMAND.COM,. Has to be there...

Yes, of course. I simply forgot this feature (you know, writing on the terminal
while looking 5m to the right on the screen of the PC isn`t as exactly as   
quoting directly via cut/paste...).

You`re entirely right about the `/C`.

The thing with the {$M x,y,z} option is still a bit foggy to me. Even the
Borland-Handbook will not elaborate it satisfactionary (to me).

In my application (starting various sub-programs within one, hmm, let`s call
it "program-server") I used all the following options: 
{$M 51200,0,0}
{$M  1024,0,0}
{$M  4096,0,0}
and I haven`t remarked any differences.

So if you can explain it once again, I might learn it.

Yours ....

PMK@CIP-S01.INFORMATIK.RWTH-AACHEN.DE     ! Warning! UNIX-Newcomer!
Michael Keukert of 2:242/2 (Fido-Net)     ! No flames please .... 
PMK@EIKO.ZER           (Zerberus-Net)     ! ... I'm still learning.              

d88-eli@nada.kth.se (Erik Liljencrantz) (09/26/89)

In article <1323@rwthinf.UUCP> pmk@cip-s08.informatik.rwth-aachen.de (Michael Keukert) writes:
>In my application (starting various sub-programs within one, hmm, let`s call
>it "program-server") I used all the following options: 
>{$M 51200,0,0}
>{$M  1024,0,0}
>{$M  4096,0,0}
>and I haven`t remarked any differences.
>
>So if you can explain it once again, I might learn it.

In the {$M x,y,z} directive the first number sets the size of the stack.
The stack is used to pass parameters to procedures and functions and to
store local variables. Recursive routines consumes much stackspace, but
also consider a chain of calling procedures, each with a string value 
parameter = at least 260 bytes stack space for each instance!
Also when hardware interupts occurs the stack is used to save the contents 
of the processor registers.

If the stack is to small, you have two options:
a. Program compiled with {$S+} detects if you are out of stack space.
b. Program compiled with {$S-} doesn't detect it and continues... Guess what
   happens (sooner or later)... 
Use {$S+} during development, and remove it if you think your code is stable.

In a small program {$M1024,0,0} might be enough, but try it with {$S+} before
you do anything serious with it...

(For an indept discusion of the stack segment (SS) and the stack pointer (SP)
 look into a book teaching assembly level programming...)

---
Erik Liljencrantz     | "No silly quotes!!"
d88-eli@nada.kth.se   |  Embraquel D. Tuta