home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 19
/
CD_ASCQ_19_010295.iso
/
dos
/
prg
/
bas
/
asilib11
/
system.doc
< prev
next >
Wrap
Text File
|
1994-10-22
|
19KB
|
594 lines
************************ ASILIB SYSTEM SUBROUTINES *************************
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
ALLOCDOS: Allocate DOS memory block. This permits dynamic memory
allocation for your ASIC programs.
Parameters: bytes&, block segment
Bytes& is the number of bytes you want to allocate. Bytes&
may be greater than 64k.
Block Segment is the segment address of the allocated memory
block. The starting offset of the memory block is always 0.
If the segment address returned by AllocDOS = 0, then
insufficient memory is available for the requested memory
block.
Restrictions: Requires ASIC's extended math option and DOS version 3.0 or
greater; if you are linking your ASIC object modules with
another library besides ASILIB, ASILIB must be specified
LAST in your list of libraries or on the command line.
Example:
REM allocate 128k bytes of DOS memory
bytes& = &hex20000&
call sub "allocdos", bytes&, memseg
REM check memory segment for errors
if memseg = 0 then
REM uh oh, not enough memory
endif
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
ASICDS: Get ASIC's default data segment.
Parameters: defaultseg
ASICDS returns the data segment in use as ASIC's default.
This segment is nessesary for several ASILIB subroutines
which require both segment and offset portions of data
addresses.
Example:
REM I want to swap the first 150 elements of arrays a() and b()
dim a(1000)
dim b(2000)
REM program fills in the arrays
.
.
.
REM get ASIC's default data segment
call sub "ASICDS", defaultseg
aptr=VARPTR(a(1))
bptr=VARPTR(b(1))
REM remember that each integer is 2 bytes
bytes=300
call sub "swapb", defaultseg, aptr, defaultseg, bptr, bytes
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
DAYNAME: Returns the name of a specified day
Parameters: DayNumber, day$
DayNumber is a number from 1 through 7, inclusive,
representing the days Sunday through Saturday.
The name of the day is returned to the calling program in
day$. Since ASIC uses 80 bytes for each string, an ASIC
string array would consume 80*7 = 560 bytes of data space.
Since ASILIB can store the day names more compactly, only
138 bytes are required for the entire DayName subroutine,
including the names of the days!
Restrictions: Assumes that DayNumber is an integer from 1 to 7.
Example:
REM I want to print "Monday" on the screen
call sub "dayname",(2,day$)
print day$
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
EXENAME: Get the name of the program.
Parameters: ProgramName$
The full program name including drive and path is returned
in ProgramName$. This is handy for finding data files
in the program's directory, among other things.
Restrictions: Requires DOS 3.0 or greater.
Example:
REM I need to get the drive and directory where this program is stored
call sub "exename", ProgramName$
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
EXESIZE: determine size of any .EXE program
Parameters: ProgramName$, ProgramSize&
ProgramName$ is a valid name of a .EXE-format disk file,
such as the ProgramName$ returned by ASILIB's EXENAME
subroutine.
ProgramSize& returned to your program is the number of bytes
in the file loaded by the DOS program loader. Additional data
may be copied to the end of a DOS .EXE file with the DOS
COPY /B command. This is handy for help screens or other such
data that you want to keep with the .EXE file, but that you
don't want to be loaded in memory with the program. If you do
copy additional data to the .EXE file, EXESize will report only
the portion of the file loaded in RAM by the DOS program loader,
while ASILIB's FSize reports the entire file size.
Restrictions: Requires ASIC's extended math option. If EXESize is called
with an invalid ProgramName$ or if other errors occur,
ProgramSize& is returned = -1. More specific information
about the nature of the error can be determined with FExist.
Errors may include file not found, access denied or
not .EXE format.
Example:
REM I've stored some data at the end of the .EXE file and now I
REM want to retrieve it.
call sub "exename", ProgramName$
call sub "exesize", ProgramName$, ProgramSize&
REM Now I can open the file & use FSEEK to position the file pointer.
.
.
.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
FLOPPIES: determine the number of floppy disk drives intalled
Parameters: No input parameters; returns n=number of floppy drives
Example:
REM determine how many floppy drives are installed
call sub "floppies", n
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
FLOPPYTYPE: determine the type of floppy disk drives intalled
Paramerters: drive$, drivetype
FLOPPYTYPE determines what kind of floppy disk drive is
installed as drive A: or drive B:. Drivetype codes returned
are:
0 = invalid drive number
1 = 360k
2 = 1.2M
3 = 720k
4 = 1.44M
Restrictions: Supports physical drives A: and B: only
Example:
call sub "floppytype", "A:", drivetype
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
FREEDOS: Release DOS memory allocated by AllocDOS and other ASILIB
subroutines.
Parameters: segment address, errcode
The segment address passed to FREEDOS must have been
allocated by ASILIB's AllocDOS subroutine or other ASILIB
subroutines which recommend using FREEDOS. Errcode = 0
normally; if an invalid segment address is used with
FREEDOS, errcode = &hex09.
Example:
REM Allocate a block of 1000 bytes, then release the block later.
call sub "allocdos", 1000&, memseg
.
.
.
call sub "freedos", memseg, errcode
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
GETDOSVER: get DOS version
Parameters: no input parameters; returns major and minor DOS versions
The Major DOS version number is 3 for version 3.x, 4 for
version 4.0, etc.; the minor version, for example, is
21 for DOS version 3.21. Some ASILIB subroutines require
DOS version 3.0 or better; if the major version is 3 or
greater, these subroutines will work OK.
Example:
call sub "getdosver", maj, min
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
INSERT: Control Insert keyboard toggle.
Parameters: Insertmode
If insertmode = 0, the Insert keyboard toggle is turned off.
If insertmode = 1, the Insert keyboard toggle is turned on.
Example:
REM turn insert toggle on
insertmode=1
call sub "insert", insertmode
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
ISATT: determines if an ATT 6300-type display card is installed
this equipment is like a CGA except that it has an additional
640 x 400 2-color graphics mode (mode &hex40)
Parameters: No input parameters; returns &hexFFFF if installed, 0 if not.
ISATT determines if an ATT 6300-type display card is installed.
This equipment is like a CGA except that it has an additional
640 x 400 2-color graphics mode (mode &hex40).
Example:
call sub "isatt", attflag
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
ISEVGA: Determines if an EGA or VGA is installed.
Parameters: No input parameters; returns monitor type, EGAVGAflag
and minimum memory.
Memory is the amount of memory as determined by standard
BIOS functions; does not attempt to detect SVGA memory
greater than 256k. EGA equipment may have memory < 256k.
If memory = 0, no EGA or VGA is installed.
EGAVGAflag = 1 if EGA, 3 if VGA.
EGA boards may be connected to either a Monochrome, CGA or
EGA monitor. If monitor = -1, CGA is used. If monitor = 0,
the EGA is driving a monochrome monitor. If monitor = 1, the
EGA is connected to an EGA or better monitor.
Example:
call sub "isevga", mon,egavga,mem
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
ISHERC: Determines if a Hercules or compatible display card
is installed and whether it is the active video system.
Parameters: Returns HercCode.
HercCode = 0 if no hercules is installed. If a Hercules
is detected, HercCode is:
128 = Hercules Graphics Card or compatible, active
144 = Hercules Graphics Card Plus, active
208 = Hercules InColor Card, active
-128 = Hercules Graphics Card or compatible, inactive
-144 = Hercules Graphics Card Plus, inactive
-208 = Hercules InColor Card, inactive
Example:
REM I want to use Hercules graphics, but first I need to determine
REM if a Hercules card is installed
call sub "IsHerc", herccode
if herccode = 0 then
REM no Hercules
else
REM use Hercules graphics
.
.
.
endif
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
ISMOUSE: determines if a mouse is installed
Parameters: No input parameters; returns mousebuttons
ISMOUSE determines if a mouse and its software driver are
installed. Mousebuttons = 0 if no mouse or no mouse driver
is installed; otherwise mousebuttons = number of buttons the
mouse has.
Example:
REM turn mouse cursor on if the mouse is installed
call sub "ismouse", mousebuttons
if mousebuttons > 0 then
call sub "showmouse"
endif
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
ISSEVGA: determines if a Super EGA or Super VGA is installed
Parameters: No input parameters; returns SVGA ID code
SVGA ID code returned by ISSEVGA is in two parts:
1) the high byte of the code tells you whether it's an EGA
or VGA
2) the low byte tells you the manufacturer
If high byte = 01, it's an EGA
If high byte = 03, it's a VGA
Low byte codes are:
1 = Paradise
2 = Everex
3 = Tseng VGA chipset
4 = Oak Technologies
5 = Western Digital (Paradise) OEM
6 = ATI
7 = Compaq
8 = NCR
9 = Trident
10 = Video7
11 = Genoa
12 = Cirrus
13 = Chips & Technologies
14 = Tseng 4000
15 = Ahead A
16 = Ahead B
17 = Trident 8900
If svgacode = 0, no SuperEGA or SuperVGA is installed.
See also IsEVGA
Example:
call sub "issevga", svgacode
if svgacode < &hex0300 then
REM either SuperEGA or no SVGA
.
.
else
REM time to decode low byte..
.
.
endif
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
GETCMD: isolates command line parameters
GetCMD assumes that parameters are separated by one or more
spaces
Parameters: commandnumber, commandtext$
GETCMD isolates one or more command-line parameters,
returning each one as commandtext$. commandnumber
determines which parameter is returned; the first command
line parameter in number 0. If the length of commandtext$
= 0, the commandnumber is greater than the actual number of
command line parameters.
Restrictions: Requires DOS version 3.0 or later.
Example:
REM I want to see if an input filename was specified when the program
REM was started
commandnumber = 0
call sub "getcmd", commandnumber, inputfile$
cmdlen=LEN(inputfile$)
if cmdlen > 0 then
REM got an input filename
.
.
.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
GETCPU: detects cpu type
Parameters: no input parameters; returns cputype code
GETCPU determines the kind of CPU in the computer. CPUType
codes are:
0 if 8086/8088
1 if 80186/80188
2 if 80286
3 if 386 (SX or DX)
4 if 486 (SX or DX)
Example:
call sub "getcpu",cputype
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
GETCRT: determines active monitor type
Parameters: No input parameters; reyurns crttype code
CPUType codes returned are:
-1 = CGA
0 = MDA
&hex0100 = EGA mono
&hex0300 = VGA mono
1 = EGA color
2 = MCGA
3 = VGA color
128 = Hercules Graphics Card
144 = Hercules Graphics Card Plus
208 = Hercules InColor
Note: GetCRT may be re-assembled with the /DNOHERC switch
to eliminate code which detects Hercules equipment
Example:
call sub "getcrt", crttype
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
MATHCHIP: determines if 80x87 math coprocessor is installed
Parameters: No input parameters; returns mathchipcode
Mathchipcodes returned by MATHCHIP are:
0 = not installed
1 = 8087
2 = 287
3 = 387 (DX or SX)
4 = 487 (486DX or 487SX)
If the coprocessor is present, it is initilaized by MathChip.
Example:
call sub "mathchip", mathchipcode
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
MONTHNAME: Returns the name of a specified month
Parameters: MonthNumber, month$
MonthNumber is a number from 1 through 12, inclusive,
representing the months January through December.
The name of the month is returned to the calling program in
month$. Since ASIC uses 80 bytes for each string, an ASIC
string array would consume 80*12 = 960 bytes of data space.
Since ASILIB can store the month names more compactly, only
170 bytes are required for the entire MonthName subroutine,
including the names of the months!
Restrictions: Assumes that MonthNumber is an integer from 1 to 12.
Example:
REM I want to print "February" on the screen
call sub "monthname",(2,month$)
print month$
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
PATH: Isolates PATHs in program enviornment
Parameters: path number, pathstring
Much like GETCMD and MONTHNAME, PATH is a pseudo string array
which returns a path from the program's enviornment block.
If the length of the string returned by PATH is zero, there
are no more paths in the enviornment block.
Restrictions: DOS 3.xx or greater
Example:
REM the PATH statement in my AUTOEXEC.BAT file looks like this:
REM PATH=C:\;C:\MASM;C:\DOS;..\
for n=0 to 100
call sub "path", n, a$
i=LEN(a$)
if i=0 then nomorepaths:
print a$
next n
REM this prints:
REM C:\
REM C:\MASM
REM C:\DOS
REM ..\
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
RAMSIZE: determine total base RAM intalled
Parameters: No input parameters; returns bytes& installed.
Note that bytes& is a long integer; requires ASIC's
extended math option.
Example:
call sub "ramsize", bytes&
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
SYSTEM: execute a second copy of COMMAND.COM; optionally runs another
program.
Parameters: command$
If command$ = "" control is transfered to another copy
of COMAMND.COM and you get the DOS prompt. Control is passed
back to the calling program when EXIT is entered at the
DOS prompt.
If command$ is the name of a program either in the current
directory or in a PATH directory, the program will be executed,
and control will pass back to the calling program at the
termination of the second program. Command$ may include
command line parameters.
Restrictions:Requires DOS 3.0 or greater
Example:
REM I want to go to DOS temporarily to format a 720k disk
command$="format a: /u /f:720"
call sub "system",command$