home *** CD-ROM | disk | FTP | other *** search
/ HomeWare 14 / HOMEWARE14.bin / prog / ramswap.arj / RAMSWAP.INT < prev    next >
Text File  |  1994-01-26  |  6KB  |  123 lines

  1. The Following is the interface section of the ramswap unit.
  2.  
  3. UNIT RAMSWAP;
  4. INTERFACE
  5.  
  6. USES dos;
  7.  
  8. PROCEDURE SwapExec(ProgramName : PathStr; Parameters : String);
  9.   
  10.   BEGIN
  11.     { Executes Program Name with command line arguments in Parameters.  }
  12.     { Implements a search of the DOS PATH for ProgramName if it does    }    
  13.     { not exist in the current directory.  If an extension is not given } 
  14.     { it searches for a .COM file first, then an .EXE file then a .BAT  } 
  15.     { file. (the same order used by COMMAND.COM)  This procedure will   }
  16.     { execute slightly faster if you supply it with the complete path to}
  17.     { the executable file, in the variable ProgramName.                 }
  18.     {.BAT files have slightly less memory to work with because a secondary}
  19.     {copy of COMMAND.COM is loaded to execute them.  .COM and .EXE files }
  20.     { are executed without loading a 2nd copy of COMMAND.COM to RAM}
  21.     
  22.     {   ****  Very Important ****  }
  23.     
  24.     {    *IF IT IS SUCCESSFUL THIS PROCEDURE DOES NOT RETURN* 
  25.     {    This procedure only returns if the program file is not found. }
  26.     {    If it successfully executes your program will terminate comp- }  
  27.     (    letely.  Any Exit procedures that have been chained will exec.}
  28.     {    The RamSwap.COM file will then gain control and actually exec-}    
  29.     {    cute the child program.  It will then restart your program    }
  30.     {    after the child terminates.  It will pass on as much info     }
  31.     {    as MS-DOS gives about program termination of the Child.       }
  32.     {    Your program will be restarting at it's first BEGIN statement }
  33.     {    in it's units initialization code or the main module.         }
  34.     {    their are several functions in this unit to help you design   }
  35.     {    your program logic to take advantage of this information.     }
  36.    END.
  37.  
  38. PROCEDURE ReadStorage(Var Target; TargetSize : Word);
  39.  
  40.    BEGIN
  41.      { a little over half of RAMSWAP.COM's memory usage is actual   }
  42.      { program code.  Almost half of it is a 1024 byte buffer which }  
  43.      { you can use to hold over data in RAM from a call to SWAPEXEC }
  44.      { to the reexecution of your program.  Read Storage should be  }
  45.      { called to read this buffer into a RECORD structure in your   }
  46.      { program.  Attempts to read greater than 1024 bytes will gen- }
  47.      { erate an error and the program will halt.                        } 
  48.      { Bounds checking is not done Target should be at least            }
  49.      { TargetSize Bytes in size or adjacent memory will be over written }
  50.    END;
  51.  
  52. PROCEDURE StoreData(Var Source; SourceSize : Word);
  53.   BEGIN
  54.     { DITTO above.   Should be called before SwapExec to store any data }
  55.     { you want to hold over from one call to the next.  All other variables }   
  56.     { will be lost because your program will terminate. 1024 byte limit }
  57.     { applies. }
  58.     { HINT: If you save EMS or XMS allocation information in this buffer     }
  59.     {       your application does not have to reallocate that type of memory }
  60.     {       when it restarts.  (unless you are using a unit type interface,  }
  61.     {       that you did not write that automatically frees that memory on   }      
  62.     {         exit)                                                          }
  63.     {       a lot of data can be held in this manner.                        }
  64.     {       if I can get enough interest generated I might be inclined to    }
  65.     {       include support for that feature in this unit or in a seperate   }
  66.     {       unit designed to work with this.                                 }
  67.   END;
  68.  
  69. PROCEDURE SwapEnd;
  70.    BEGIN
  71.      { Since RAMSWAP.COM is in control of your application a standard HALT }
  72.      { or exiting at the END. in your main program file will just put you }  
  73.      { in an infinite loop.  Call SwapEnd when you really want to quit.   }
  74.      { ** FLASH I'm giving you some source code.}
  75.      { If you don't want to call SwapEnd. just put the statement HALT(17) }
  76.      { where you want to end your program execution. }
  77.    END;
  78.  
  79. FUNCTION  Child_Had_Error : BOOLEAN;
  80.   BEGIN
  81.     {Returns TRUE if DOS encountered an error while executing the last
  82.     child program from RAMSWAP.COM}
  83.   END;
  84.  
  85. FUNCTION  SwapChildDosError : INTEGER;
  86.   BEGIN
  87.     {If Child_Had_Error then SwapChildDosError will return the
  88.      standard DOS error code encountered. If Child_Had_Error returns
  89.     FALSE this function returns a -1}
  90.   END;
  91.   
  92. FUNCTION  SwapChildExitCode : INTEGER;
  93.   BEGIN 
  94.     { If DOS didn't encounter an error then SwapChildExitCode will
  95.       return the Exit code of the last process executed by RAMSWAP.
  96.       if an error was encountered returns a -1}
  97.   END;
  98.  
  99. FUNCTION  IsFirstPass       : BOOLEAN;
  100.   BEGIN
  101.     { This function is very important when developing using RAMSWAP.COM
  102.       since program flow will not follow the conventional path this 
  103.       function should be called very near the start of your program.
  104.       It will tell the program wheather or not This is the first time
  105.       it has been loaded (IsFirstPass = TRUE) or if it is being reexecuted
  106.       after a child process has terminated (IsFirstPass=FALSE) 
  107.       This should indicate to the program that it has information to 
  108.       retrieve from the storage buffer *SEE ReadStorage ABOVE* that it
  109.       can use to make a decision on it's next action.};
  110.    END;
  111.  
  112.  
  113. FUNCTION  SwapModulePresent : BOOLEAN;
  114.   BEGIN
  115.     { This tells your program is RAMSWAP.COM is resident in memory }
  116.     { returns FALSE if RAMSWAP.COM is not.                         } 
  117.     { you don't really need to call this though because the RAMSWAP}
  118.     { unit terminates the program with an error message if it was  }
  119.     { not loaded from the RAMSWAP.COM swap driver.                 }
  120.  END.
  121.         
  122.  
  123.