User:Andrew Nikitin/timecalc

From J Wiki
Jump to navigation Jump to search
require '~nsg/geo/angular.ijs'
require '~nsg/gui/bui.ijs'

T=:0 : 0
xywh %2;cc ccsatic static;cn "%0";
xywh %3;cc %1 edit;
)

fs_run=:3 : 0
wd 'pc fs closeok;pn "Order calculator";'

NB. input section
n=.'nparts';'timetobuild';'orderbegin';'orderend'
d=.'Parts in sample';'Time to build sample';'Order starts at';'Order must end at'

ir=. 5 5 moveby 0 2{"2 (12#~#n) controlgrid 70 3 60
wd ; T template d,.n,.<"1 ir

NB. action section
t=.runion rravel ir
br=.(15+0{t),(5++/1 3{t),80 15
wd 'xywh ',(":br),';cc calc button;cn "Calculate";'

NB. output section
n=.'perone';'amount'
d=.'time per part';'amount to build'


or=. ((0{t) , 5++/1 3{br) moveby 0 2{"2 (12#~#n) controlgrid 70 3 60
wd ; T template d,.n,.<"1 or

wd 'pas 5 5;pshow;'
wd 'set nparts 888'
wd 'ptop 1'
)

fs_top=: wd bind 'psel fs;ptop 1'

to_hours=:3 : '(24*{.t)+cms }.t=._4{.y'

fs_calc_button=:3 : 0
  n=.1 ". nparts
  t=._4{.0".timetobuild
  p1=.n%~to_hours 0". timetobuild
  amt=.p1%~orderend -&([: to_hours _4 {. 0&".) orderbegin

  wd 'set perone *',":2 cms p1
  wd 'set amount *',":amt
)