BBS: Inland Empire Archive Date: 03-24-92 (03:24) Number: 198 From: DARYL POSNETT Refer#: NONE To: DUANE BURRIS Recvd: NO Subj: DOS Prompt 2/ Conf: (2) Quik_Bas
>>> Continued from previous message
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Get the master enviroment segment
'
'
FUNCTION GetMasterEnvSeg%
DIM Regs AS RegTypeX
Regs.ax = &H352E
CALL INTERRUPTX(&H21, Regs, Regs)
DEF SEG = Regs.es
GetMasterEnvSeg% = PEEK(&H2C) + PEEK(&H2D) * 256
DEF SEG
END FUNCTION
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Get the master enviroment size in bytes
'
'
FUNCTION GetMasterEnvSize%
DEF SEG = GetMasterEnvSeg% - 1
Size% = (PEEK(3) + PEEK(4) * 256) * 16
DEF SEG
GetMasterEnvSize% = Size%
END FUNCTION
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Get a master enviroment variable
'
'
FUNCTION GetMasterEnvVar$ (EnvVar$)
status% = GetMasterEnvVarInfo%(EnvVar$, EnvDef$, EnvSize%)
GetMasterEnvVar$ = EnvDef$
END FUNCTION
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Get a master enviroment variable and it's location
'
' returns 0 on sucess, -1 if variable is not in enviroment
'
'
FUNCTION GetMasterEnvVarInfo% (EnvVar$, EnvDef$, EnvLoc%)
MaxSize% = GetMasterEnvSize%
DEF SEG = GetMasterEnvSeg%
EnvAdr% = 0
found% = 0
DO
temp$ = "": EnvLoc% = EnvAdr%
WHILE PEEK(EnvAdr%) <> 0 AND EnvAdr% < MaxSize% - 1
temp$ = temp$ + CHR$(PEEK(EnvAdr%))
EnvAdr% = EnvAdr% + 1
WEND
IF PEEK(EnvAdr% + 1) <> 0 THEN EnvAdr% = EnvAdr% + 1
cntr% = INSTR(temp$, "=")
IF cntr% = 0 THEN
temp$ = ""
ELSE
IF LEFT$(temp$, cntr% - 1) = EnvVar$ THEN
EnvDef$ = RIGHT$(temp$, LEN(temp$) - cntr%)
found% = -1
temp$ = ""
END IF
END IF
IF EnvAdr% >= MaxSize% THEN temp$ = ""
LOOP UNTIL temp$ = ""
GetMasterEnvVarInfo% = NOT found% ' return status
END FUNCTION
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Set a master enviroment variable
'
' Adds variable to end of list if it isn't in the enviroment
'
' returns 0 on success, -1 if out of enviroment space
'
FUNCTION SetMasterEnvVar% (EnvVar$, EnvDef$)
'
' prepend var name and new defintion to output string
'
rest$ = EnvVar$ + "=" + EnvDef$ + CHR$(0)
status% = GetMasterEnvVarInfo%(EnvVar$, CurDef$, VarBeg%)
IF status% = 0 THEN
'
' point to end of current variable and definition
'
VarEnd% = VarBeg% + LEN(EnvVar$) + LEN(CurDef$) + 2
EnvAdr% = VarEnd%
>>> Continued to next message
___
X SLMR 2.0 X Have you tried an Applied Design Group product today ?
--- Maximus 2.00
* Origin: Inland Empire Archive (1:346/10)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET