\ ENVIRON.HLP   Environment manipulation words          by Tom Zimmer

evseg           ( --- n1 )
        Return n1 the value of the environment segment.

envsize         ( --- n1 )
        Calculate n1 the size of the environment in bytes, clipped
        to about 31k bytes.

"envfind        ( a1 n1 --- n2 bool )
        Search the environment for the string specified by a1,n1.
        Return a boolean flag TRUE if found, and n1 the offset
        into the environment where the match occured.

.env            ( --- )
        Display the current contents of the environment string.

comspec$        ( --- a1 )
        The handle used to hold the COMSPEC string. I.e. COMMAND.COM

comspec@        ( --- )
        Read the environment string, and extrac the COMSPEC
        parameter. the COMSPEC is inserted in the COMSPEC$ handle.

.comspec        ( --- )
        Print the current COMSPEC.

handle me$

: me@           ( --- ) \ extract my own execution name string
                me$ dup off 2 "envfind 0=
                abort" Couldn't find my execution name."
                4 + envsize swap
                me$ dup clr-hcb >nam -rot
                do      evseg i c@l 0= ?leave
                        evseg i c@l over c! 1+
                        me$ c@ 1+ me$ c!
                loop    drop ;

: .me           ( --- ) me@ me$ count type ;

comment:

envsize       ( --- n1 )
        Return the maximum size the environment can be in bytes.

.env          ( --- )
        Print the environment string used by the system.

"envfind      ( a1 n1 --- n2 bool )
        Find the string a1 n1 in the environment, returning
        bool true if found, and n2 the offset into env$ where it
        was found. N2 is the offset to the BEGINNING of the
        string searched for.

comspec$
        Storage space for the command spec string.

comspec@      ( --- )
        Extract the command spec from the environment string.

.comspec      ( --- )
        Print the command spec.

path$         ( --- a1 )
        Storage space for the PATH string.

path@         ( --- )
        Extract the PATH from the environment string.

.path         ( --- )
        Print the PATH.

me$
        Storage space for the execution string used to execute
        this forth currently running.

me@           ( --- )
        Extract the execution string from the environment, and
        place it in the string ME$

.me           ( --- )
        Print the execution string after extracting it.

comment;


