\ ENVIRON.SEQ Environment manipulation words by Tom Zimmer : evseg ( --- n1 ) \ Return the segment of environment $. 44 @ ; : envsize ( --- n1 ) \ Calculate the environment $ size. ?cs: evseg - 2047 min 16 * ; : "envfind ( a1 n1 --- n2 bool ) caps dup @ >r off evseg SSEG ! \ Set the search segment 0 envsize search ?CS: SSEG ! \ Restore the search segment r> caps ! ; : .env ( --- ) \ print the environment string 0 envsize bounds cr ?do evseg i c@l 0= if cr else evseg i c@l emit then evseg i @l 0= ?leave loop ; handle comspec$ : comspec@ ( --- ) \ extract the command spec " COMSPEC=" "envfind 0= abort" Couldn't find Command Spec." 8 + envsize swap comspec$ dup clr-hcb >nam -rot do evseg i c@l 0= ?leave evseg i c@l over c! 1+ comspec$ c@ 1+ comspec$ c! loop drop ; : .comspec ( --- ) comspec@ comspec$ count type ; 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. 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;