NB. sysenv - System Environment
NB.
NB. ---------------------------------------------------------
NB. Main definitions are in z:

NB. ---------------------------------------------------------
NB. verbs:
NB.*jhostpath v    converts path name to use host path separator
NB.*jcwdpath v     adds path to J current working directory
NB.*jsystemdefs v  loads appropriate netdefs or hostdefs

NB. ---------------------------------------------------------
NB. nouns:
NB. (fonts are redefined in configuration)
NB.*   ARGV n         command line
NB.*   PROFILE n      name of profile file
NB.*   FIXFONT n      fixed space font (used in session windows)
NB.*   PROFONT n      proportional font (used in forms)
NB.*   IF64 n         if a 64 bit J system
NB.*   IFCONSOLE n    if a console front end
NB.*   IFJAVA n       if a Java front end
NB.*   IFUNIX n       if UNIX
NB.*   IFWIN32 n      if Windows (9x,ME,NT,2000,XP)
NB.*   IFWINNT n      if Windows NT,2000,XP
NB.*   IFWINCE n      if Windows CE
NB.*   UNAME n        name of UNIX o/s

NB. Other nouns defined in j:
NB.*   JIJX n         1 if -jijx parameter (i.e. don't create ijx window)

18!:4 <'z'

NB. =========================================================
3 : 0 ''

notdef=. 0: ~: 4!:0 @ <

if. notdef 'ARGV' do. ARGV=: <'undefined' end.
if. notdef 'PROFILE' do. PROFILE=: 1!:45'' end.
if. notdef 'PATHSEP_j_' do. PATHSEP_j_=: '/\'{~6=9!:12'' end.
jhostpath=: PATHSEP_j_ & (I. @ (e.&'/\')@] })
if. notdef 'IFJIJX_j_' do. IFJIJX_j_=: (<'-jijx') = 1 { ARGV,a: end.

NB. ---------------------------------------------------------
IF64=: 16={:$3!:3[2 NB. possibly better tests don't work yet
IFCONSOLE=: 0 -: (11!:0) :: 0: ''
IFJAVA=: 'jjava'-: (11!:0) :: 0: 'qwd'
'IFUNIX IFWIN32 IFWINCE'=: 5 6 7 = 9!:12''

NB. ---------------------------------------------------------
if. IFUNIX do.
  UNAME=: (2!:0 'uname')-.10{a.
else.
  UNAME=: 'Win32'
end.

NB. ---------------------------------------------------------
NB. get Windows NT flag
if. IFWIN32 do.
  'hi lo'=. 256 256 #: > {. 'kernel32 GetVersion i' 15!:0 ''
  IFWINNT=: (hi = 0) +. lo > 4
else.
  IFWINNT=: 0
end.

NB. ---------------------------------------------------------
if. IFJAVA do.
  if. notdef 'FIXFONT' do. FIXFONT=: 'monospaced 12' end.
  if. notdef 'PROFONT' do. PROFONT=: 'sansserif 10' end.
else.
  if. notdef 'FIXFONT' do. FIXFONT=: '"Courier New" 12' end.
  if. notdef 'PROFONT' do. PROFONT=: '"MS Sans Serif" 8' end.
end.
)

NB. =========================================================
jcwdpath=: (1!:43@(0&$),])@jhostpath@((*@# # '\'"_),])

NB. =========================================================
jsystemdefs=: 3 : 0
0!:0 <jpath '~system\main\defs\',y.,'_',(tolower UNAME),(IF64#'_64'),'.ijs'
)
