NB. built from project: ~Source\main\newuser\newuser

coclass 'jnewuser'


0!:0 <jpath '~system\main\text.ijs'
quote=: ''''&,@(,&'''')@(#~ >:@(=&''''))
wdbuf=: 3 : 'BUF=: BUF,<y.'
shownewuser=: 3 : 0
new=. 'NEWUSER=: ',":{.y.,0
dat=. cfgopen''
if. 0 = #dat do. return. end.
ndx=. 1 i.~ (<'NEWUSER=') = 8 {.each dat
if. ndx = #dat do. dat=. dat , <'' end.
cfgwrite (<new) ndx } dat
)


USERFNAME=: USERLNAME=: USERJUL=: ''
TJUL=: '0'
0!:0 :: ] <jpath '~config\config.ijs'

deb=: #~ (+. 1: |. (> </\))@(' '&~:)
fexist=: 1!:4 :: 0:
fread=: 1!:1 :: 0:
fwrite=: 1!:2 :: 0:
jval=: 3 : 0
USERNAME=: deb USERFNAME,' ',USERLNAME
if. USERJUL -: TJUL do.
  val=: 4;''
else.
  val=: 3;''
  0!:0 :: ] <jpath '~system\extras\util\jul.ijl'
end.
)
cfgopen=: 3 : 0
CFG=: jpath '~config\config.ijs'
if. 0 -: fexist <CFG do.
  dat=. fread < jpath '~system\extras\config\stdcfg.ijs'
  dat fwrite <CFG
end.
dat=. fread <CFG
if. 0 -: dat do.
  msg=. 'Unable to save configuration file: ',CFG
  if. IFCONSOLE do.
    msg 1!:2 [ 2
  else.
    wdinfo 'New User';msg
  end.
  '' return.
end.
<;._2 (toJ dat), LF
)
cfgwrite=: 3 : 0
dat=. toHOST ; ,&LF each y.
dat fwrite <CFG
)
jul_info=: 3 : 0
jval''
if. IFCONSOLE do.
  info=. ] (1!:2) 2:
else.
  info=. wdinfo @ ('J User License'&;)
end.
select. 0 pick val
case. 0 do.
  info 'J User License recorded'
case. 1 do.
  info 'Invalid License. This is for release J',(":1 pick val),'.'
case. 2 do.
  info 'First enter the User License.'
case. 3 do.
  msg=. 'Please check your name and license is exactly that provided.'
  info 'License is invalid for ',JVER,'.',LF,LF,msg
case. 4 do.
  info 'Temporary J User License entered.'
end.
)
jul_fmt=: 3 : 0
dat=. (,y.) -. ' ./-'
if. 11 = #dat do.
  dat 0 1 2 3 5 6 7 9 10 11 12 } 13 # '-'
else.
  dat
end.
)
jul_write=: 3 : 0
dat=. cfgopen''
if. 0 = #dat do. return. end.
new=. ''
new=. new,<'USERJUL=: ',quote jul_fmt USERJUL
new=. new,<'USERFNAME=: ',quote USERFNAME
new=. new,<'USERLNAME=: ',quote USERLNAME
msk=. -. (7 {.each dat) e. 'USERJUL';'USERFNA';'USERLNA'
ndx=. msk i. 0
dat=. msk # dat
cfgwrite (ndx {. dat),new,ndx }. dat
)


jval_close=: 3 : 0
if. -. NOJUL do. 1 return. end.
jul_get''
jul_set''
jul_info''
if. 0 = 0 pick val do.
  jul_write''
end.
(0 pick val) e. 0 4
)
jul_get=: 3 : 0
USERFNAME=: deb userfname
USERLNAME=: deb userlname
USERJUL=: jul_fmt userjul
)
jul_set=: 3 : 0
wd 'set userfname *',USERFNAME
wd 'set userlname *',USERLNAME
wd 'set userjul *',USERJUL
if. 1 = 0 pick val do.
  ver=. '(J',(": 1 pick val),')'
else.
  ver=. ''
end.
wd 'set userjulver *',ver
)



NEWUSERHDR=: topara 0 : 0
If you are new to J, you might start by going through some of the Labs.
Then look at the Primer, which introduces the language and working
environment, and at the various Demos.

The complete J documentation can be accessed through the Help menu.

All users should check out the Release Highlights.

We encourage you to join the J Forum, which is the main discussion group
for all topics related to J. For details, see: http://www.jsoftware.com.
)
NEWUSERJUL=: topara 0 : 0
You need a X User License (JUL) to program in J.
Get your free JUL from www.jsoftware.com and enter it below.
If you do not yet have a JUL, leave the name fields blank and
enter the temporary license number: Z.
)
NEWUSERWD=: 0 : 0
pc newuserwd nomax nosize owner;
xywh 8 5 290 15;cc w0 static ss_center;cn "";
xywh 8 20 292 84;cc g0 groupbox;cn "";
xywh 13 26 283 74;cc hdr static;cn "";
xywh 8 110 292 58;cc g1 groupbox;cn "Key Menu Items";
xywh 13 121 77 10;cc s0 static;cn "";
xywh 92 121 201 10;cc n0 static;cn "";
xywh 13 132 77 10;cc s1 static;cn "";
xywh 92 132 201 10;cc n1 static;cn "";
xywh 13 143 77 10;cc s2 static;cn "";
xywh 92 143 201 10;cc n2 static;cn "";
xywh 13 154 77 10;cc s3 static;cn "";
xywh 92 154 201 10;cc n3 static;cn "";
)

NEWUSERWD1=: 0 : 0
xywh 8 174 292 88;cc g2 groupbox;cn "User License";
xywh 13 185 282 28;cc s4 static;cn "";
xywh 12 217 55 11;cc s5 static;cn "First Name:";
xywh 69 216 80 12;cc userfname edit ws_border es_autohscroll;
xywh 12 232 55 11;cc s6 static;cn "Last Name:";
xywh 69 231 80 12;cc userlname edit ws_border es_autohscroll;
xywh 12 246 55 11;cc s7 static;cn "User License:";
xywh 69 245 80 12;cc userjul edit ws_border es_autohscroll;
xywh 155 246 55 11;cc userjulver static;cn "";
xywh 9 268 157 11;cc show checkbox;cn "";
xywh 226 267 72 12;cc exitj button bs_defpushbutton;cn "E&xit to J Session";
pas 6 6;pcenter;
)

NEWUSERWD2=: 0 : 0
xywh 8 174 292 33;cc g2 groupbox;cn "User License";
xywh 13 185 282 20;cc s4 static;cn "";
xywh 9 214 157 11;cc show checkbox;cn "";
xywh 225 214 72 12;cc exitj button bs_defpushbutton;cn "E&xit to J Session";
pas 6 6;pcenter;
)
newsetfont=: 3 : 0
nms=. > ;: y.
wdbuf ,';setfont ',"1 nms,"1 ' ',FONT
)
newsetfont2=: 3 : 0
wdbuf 'setfont ',y.,' ',FONT2
)
newuserwd_run=: 3 : 0
newuserdefs''
BUF=: ''
wdbuf NEWUSERWD

if. NOJUL do.
  wdbuf NEWUSERWD1
else.
  wdbuf NEWUSERWD2
end.

wdbuf 'set hdr "',NEWUSERHDR,'"'
pn=. 'Welcome to ',JVER
wdbuf 'pn "',pn,'"'
wdbuf 'setcaption w0 "',pn,'"'
newsetfont2 'w0'

wdbuf 'setcaption n0 "For new features and recent changes to the system"'
wdbuf 'setcaption s0 "Help|Release Highlights"'
wdbuf 'setcaption n1 "To configure your system, e.g. change the fonts"'
wdbuf 'setcaption s1 "Edit|Configure..."'
wdbuf 'setcaption n2 "To run a Lab"'
wdbuf 'setcaption s2 "Studio|Labs..."'
wdbuf 'setcaption n3 "To run a Demo"'
wdbuf 'setcaption s3 "Studio|Demos..."'

if. NOJUL do.
  newsetfont 'g0 g1 g2 s0 s1 s2 s3 s4 s5 s6 s7 n0 n1 n2 n3'
  newsetfont 'hdr exitj show userfname userlname userjul userjulver'
  wdbuf 'setcaption s4 "',NUJ,'"'
  wdbuf 'setcaption show "Do not show this form again (requires a JUL)"'
else.
  newsetfont 'g0 g1 g2 s0 s1 s2 s3 s4 n0 n1 n2 n3'
  newsetfont 'hdr exitj show'
  txt=. toJ 'Name: ',USERNAME,LF,'License: ',USERJUL
  wdbuf 'setcaption s4 "',txt,'"'
  wdbuf 'setcaption show "Do not show this form again"'
end.
wdbuf 'setfocus exitj'

BUF=: ; BUF ,each ';'
wd BUF
if. NOJUL do.
  jul_set''
end.
wd 'pshow'
)
newuserdefs=: 3 : 0
ver=. (i.&'/' {. ])9!:14''
JVER=: 'J',(({.ver) e. 'jJ') }. ver
if. IFJAVA do.
  FONT=: 'sansserif 12'
  FONT2=: 'sansserif 16 bold'
else.
  FONT=: '"MS Sans Serif" 12'
  FONT2=: '"MS Sans Serif" 16 bold'
end.
jval''
NOJUL=: 0 < 0 pick val
if. NOJUL do.
  TJUL=: 7{.|.4}.' .'-.~":6!:0 ''
  i=. NEWUSERJUL i.'X'
  NUJ=: (i{.NEWUSERJUL),JVER,}.i}.NEWUSERJUL
  i=. NUJ i.'Z'
  NUJ=: (i{.NUJ),TJUL,}.i}.NUJ
end.
)
newuserwd_show_button=: 3 : 0
if. -. NOJUL do. 1 return. end.
jul_get''
jval''
if. 0 ~: 0 pick val do.
  wdinfo 'J User License';'First enter a valid JUL.'
  wd 'set show 0'
end.
)
newuserwd_cancel=: 3 : 0
if. -. 2 wdquery JVER;'Do you want to close?' do.
  2!:55''
end.
)
newuser_close=: 3 : 0
if. -. jval_close'' do. return. end.
if. (". show) *. 0 = 0 pick val do.
  shownewuser 0
end.
if. 0 pick val do.
  shownewuser 1
end.
wd 'pclose'
coerase <'jnewuser'
)
newuserwd_close=: newuserwd_cancel
newuserwd_enter=: newuserwd_exitj_button=: newuser_close
newuserwd_userfname_button=: newuser_close
newuserwd_userlname_button=: newuser_close
newuserwd_userjul_button=: newuser_close


newuserwd_run''