home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_BAS
/
SWAPBAS.ZIP
/
SWAPOUT.BAS
< prev
Wrap
BASIC Source File
|
1994-02-16
|
3KB
|
90 lines
' This function returns the ErrorLevel in ELRC%
' Program memory is swapped to EMS/XMS/DISK, whichever is found first
' Link SWAPBAS.OBJ into your program FIRST so as to reduce the
' memory requirements can leave a stub file as small as 2400 bytes
' Prog2Run$ MUST be a fully named file, the path is NOT searched!!!!
' It is a GOOD idea to fully name SwapFile$ also because a disaster could
' occur if it is not found on return
' Memory.Swap returns TRUE (-1) if a successful swap occured
' or FALSE (0) if the swap failed
DECLARE FUNCTION Memory.Swap% (Prog2Run$, ProgCmdLine$, ELRC%, SwapFile$)
DECLARE FUNCTION XMScheck% ()
DECLARE FUNCTION EMScheck% ()
DECLARE FUNCTION SWAPBAS% (SEG SwapPack AS ANY)
TYPE SwapPackTYPE 'Do not change the sizes of these*
statexec AS INTEGER 'To simplify this use this static structure
ProgName AS STRING * 128 'to pass info. The 384 bytes it uses is made
CmdLine AS STRING * 126 'up in ease-of-use and the lack of need to
SaveFile AS STRING * 128 'constantly assign pointers if these were such.
END TYPE '(*unless you change the SWAPBAS.ASM source)
DIM SWAPIT AS SwapPackTYPE
' EXAMPLE CODE
'Prog2Run$ = COMMAND$
'Swapfile$ = "swapper.swp"
'a% = Memory.Swap%(prog2run$,progcmdline$,ELRC%,swapfile$)
'PRINT "Error level returned is"; ELRC%
'CLOSE ' I do this before I end ANY program
'CLEAR ' I do this before I end ANY program
'end
FUNCTION Memory.Swap% (prog2run$, progcmdline$, ELRC%, SwapFile$)
SHARED SWAPIT AS SwapPackTYPE
SHARED Memoryswapping
IF progcmdline$ = "" THEN progcmdline$ = " "
IF SwapFile$ = "" THEN SwapFile$ = "A1B2C3E4.SWP"
LastLine = CSRLIN
PCOPY 0, 1
CLS
SWAPIT.statexec = 0
SWAPIT.ProgName = prog2run$ + CHR$(0)
SWAPIT.CmdLine = progcmdline$ + CHR$(0)
SWAPIT.SaveFile = SwapFile$ + CHR$(0)
SELECT CASE Memoryswapping
CASE 0
PRINT "Swapping ..."
statSWAP = SWAPBAS(SWAPIT)
IF statSWAP THEN
Memory.Swap% = 0
SELECT CASE statSWAP
CASE 1
PRINT "Memory SWAP failed; Unable to shrink DOS memory block"
CASE 2
PRINT "Memory SWAP failed; Unable to save current task to EMS/XMS/DISK"
CASE 3
PRINT "Memory SWAP failed; Unable to execute " + prog2run$
SELECT CASE SWAPIT.statexec
CASE 2
PRINT "File not found"
CASE 5
PRINT "Access denied"
CASE 8
PRINT "Insufficient memory"
CASE ELSE
END SELECT
CASE ELSE
END SELECT
PRINT "Executing " + prog2run$ + " in a standard DOS shell"
SHELL prog2run$ + " " + progcmdline$
ELSE
PRINT prog2run$ + " returns errorlevel" + STR$(SWAPIT.statexec)
ELRC% = SWAPIT.statexec
Memory.Swap% = statSWAP
END IF
CASE 1
SHELL prog2run$ + " " + progcmdline$
Memory.Swap% = -1
CASE ELSE
END SELECT
SLEEP 3
PCOPY 1, 0
LOCATE LastLine
END FUNCTION