\ Define all 15 resident libs...
\
\ 06/12/88 mdh added rehash, changed name to :Library
\ MOD: PLB 1/11/89 Changed MathIEESingBas to MathIEEEDoubTrans

: :Library   ( -- , build a JForth Library structure for handling calls )
  bl word  ( here -- ) >r  unword
  $" _LIB"  count r>  $append   here find swap drop 0=
  IF     skip-word  [compile] variable ( globals )
  THEN
  bl word  ( here -- ) >r  unword
  $" _NAME" count r>  $append   [compile] ((create))
  COMPILE ($")  bl word  ( Put string into dictionary. )  >r
  r 1+  r c@ 0           ( switch string to lower case )
  DO   dup c@ ?letter
       IF  dup c@   bl or over c!
       THEN  1+
  LOOP drop
  0" .library" 1-  count  r@  $append
  r>   c@ 1+ even-up allot   compile 1+
$ 4e75 w,  unsmudge  [compile] [
  last-sfa   $ 4000,0000  or  swap !  rehash  ;

:Library exec
:Library clist
:Library graphics
:Library layers
:Library intuition
:Library mathffp
:Library mathtrans
:Library mathieeedoubbas
:Library dos
:Library translator
:Library icon
:Library diskfont
:Library console
:Library mathieeedoubtrans
:Library potgo
:Library timer

\ -------------- words to open/close libs convieniently ------------

user LibVersion

: openlib   ( name_addr -- pointer/false )
  >abs  LibVersion @  ( absadr version -- )  call exec_lib openlibrary
  LibVersion off   ;

: closelib  ( lib_pointer -- 0 )
  call exec_lib  closelibrary          ;


: lib?   ( _NAME-adr _LIB-adr -- , insures lib is open and var is set )
  dup @ 0=  ( -- name lib flag )
  IF    over  openlib  -dup
        IF    ( name-adr lib-adr lib-pointer -- )   over !
        ELSE  drop >r .err ." Can't open any version of "
              r>  1- $type quit
        THEN
  THEN  2drop   ;

: exec? ;          \ always open in JForth
: dos?  ;          \ always open in JForth
: clist?           ( -- )  clist_NAME            clist_LIB            lib?  ;
: graphics?        ( -- )  graphics_NAME         graphics_LIB         lib?  ;
: layers?          ( -- )  layers_NAME           layers_LIB           lib?  ;
: intuition?       ( -- )  intuition_NAME        intuition_LIB        lib?  ;
: mathffp?         ( -- )  mathffp_NAME          mathffp_LIB          lib?  ;
: mathtrans?       ( -- )  mathtrans_NAME        mathtrans_LIB        lib?  ;
: mathieeedoubbas? ( -- )  mathieeedoubbas_NAME  mathieeedoubbas_LIB  lib?  ;
: translator?      ( -- )  translator_NAME       translator_LIB       lib?  ;
: icon?            ( -- )  icon_NAME             icon_LIB             lib?  ;
: diskfont?        ( -- )  diskfont_NAME         diskfont_LIB         lib?  ;
: console?         ( -- )  console_NAME          console_LIB          lib?  ;
: mathieeedoubtrans? ( -- )  mathieeedoubtrans_NAME
      mathieeedoubtrans_LIB  lib?  ;
: potgo?           ( -- )  potgo_NAME            potgo_LIB            lib?  ;
: timer?           ( -- )  timer_NAME            timer_LIB            lib?  ;

: -lib   ( _LIB-adr -- )
  dup @ -dup
  IF    call exec_lib closelibrary  ( -- retcode ) drop
        0 over !
  THEN  drop   ;


: -exec  ;         \ error to close exec in JForth
: -dos   ;         \ error to close dos  in JForth
: -clist           ( -- )  clist_LIB            -lib  ;
: -graphics        ( -- )  graphics_LIB         -lib  ;
: -layers          ( -- )  layers_LIB           -lib  ;
: -intuition       ( -- )  intuition_LIB        -lib  ;
: -mathffp         ( -- )  mathffp_LIB          -lib  ;
: -mathtrans       ( -- )  mathtrans_LIB        -lib  ;
: -mathieeedoubbas ( -- )  mathieeedoubbas_LIB  -lib  ;
: -translator      ( -- )  translator_LIB       -lib  ;
: -icon            ( -- )  icon_LIB             -lib  ;
: -diskfont        ( -- )  diskfont_LIB         -lib  ;
: -console         ( -- )  console_LIB          -lib  ;
: -mathieeedoubtrans ( -- )  mathieeedoubtrans_LIB  -lib  ;
: -potgo           ( -- )  potgo_LIB            -lib  ;
: -timer           ( -- )  timer_LIB            -lib  ;
