jax@well.sf.ca.us (Jack J. Woehr) (03/28/91)
\ getenv.f ... environment variable fetching in jforth 2.0
\ (C) 1991 jack j. woehr jax@well.UUCP JAX on GEnie
\ Permission to use freely is hereby granted.
ANEW TASK-GETENV
$ 100 constant env$bufln
" ENV:" create env$buf \ -- $addr
count dup allot \ -- addr ct
env$buf swap move \ --
here env$bufln allot \ -- here
constant (env$buf) \ --
: env$buf.init (env$buf) env$bufln 0 fill ;
\ get an environment variable up to ENV$BUFLN long from a counted string
: getenv ( $adr -- addr ct)
env$buf.init
count (env$buf) swap move
env$buf 0fopen
dup
if
dup
(env$buf) env$bufln fread
swap fclose
then
(env$buf) swap
;
\ Typical usage
\
\ " EDITOR" GETENV
\
\ ... would yield addr and (possibly zero) count of EDITOR environment string.
\ *** End of GETENV.F
--
<jax@well.{UUCP,sf.ca.us} >< Member, > /// ///\\\ \\\ ///
<well!jax@lll-winken.arpa >< X3J14 TC > /// /// \\\ \\\///
<JAX on GEnie >< for ANS > \\\ /// ///====\\\ ///\\\
<SYSOP RCFB (303) 278-0364>< Forth > \\\/// /// \\\ /// \\\