r/tinycode • u/johnorork • Apr 02 '14
REBOL ENTRY PROGRAM
REBOL [title: "Job File"]
write/append %jobdata.txt "" database: load %jobdata.txt
gui: layout [
text bold "Load an existing record:"
name-list: text-list bold font-size 15 blue 250x100 data sort (extract database 12) [
if value = none [return]
marker: index? find database value
id/text: pick database marker
nm/text: pick database (marker + 1)
pd/text: pick database (marker + 2)
ow/text: pick database (marker + 3)
ls/text: pick database (marker + 4)
yo/text: pick database (marker + 5)
yp/text: pick database (marker + 6)
sd/text: pick database (marker + 7)
pt/text: pick database (marker + 8)
ayt/text: pick database (marker + 9)
rt/text: pick database (marker + 10)
pm/text: pick database (marker + 11)
clear-calcs
show gui]
guide
text bold "Job ID:" id: field 100 bold font-size 15
text bold "Name:" nm: field 100 bold font-size 15
text bold "Pour Start Date:" pd: field 100 bold font-size 15
text bold "One Way Travel:" ow: field 100 bold font-size 15
text bold "Load Size:" ls: field 100 bold font-size 15
text bold "YPH Ordered:" yo: field 100 bold font-size 15
return
text bold "Yards in Pour:" yp: field 100 bold font-size 15
text bold "Slab Depth:" sd: field 100 bold font-size 15
text bold "Pour Start Time:" pt: field 100 bold font-size 15
text bold "Added Yard Time:" ayt: field 100 bold font-size 15
text bold "Additional Return Time:" rt: field 100 bold font-size 15
text bold "Pump Move Time:" pm: field 100 bold font-size 15
return
text bold "Maximum YPH:" my: field 75 bold font-size 15
text bold "Unload Time:" ut: field 75 bold font-size 15
text bold "Total Trip Time:" ttt: field 75 bold font-size 15
text bold "Yds Per Truck Hour:" ypt: field 75 bold font-size 15
text bold "Actual Trucks Required:" atr: field 75 bold font-size 15
text bold "Optimum Trucks Required:" otr: field 75 bold font-size 15
text bold "Maximum Trucks Required:" mtr: field 75 bold font-size 15
text bold "Trucks Required using YPH Ordered:" rto: field 75 bold font-size 15
return
text bold "First Batch Start Time:" fbs: field 75 bold font-size 15
text bold "YPH using Optimal Trucks:" ypo: field 75 bold font-size 15
text bold "Added Gap:" ag: field 75 bold font-size 15
text bold "Total Trucks Loaded at One Time:" ttl: field 75 bold font-size 15
text bold "Pour Time Max Trucks:" ptm: field 75 bold font-size 15
text bold "Pour Time Opt Trucks:" pto: field 75 bold font-size 15
text bold "Total Number of Trips:" tt: field 75 bold font-size 15
text bold "Mins Out of Concrete using Opt:" moc: field 75 bold font-size 15
return
text bold "Minimum Yds at Pump:" myp: field 75 bold font-size 15
text bold "Total Mins Wasted using Max:" tmw: field 75 bold font-size 15
text bold "Adjusted Truck Count if Limited Access:" atc: field 75 bold font-size 15
text bold "Total Lost Hours to Pump Move:" tlp: field 75 bold font-size 15
text bold "Wasted Assets Using YPH:" wa: field 75 bold font-size 15 red
text bold "Substitute Slab Depth Limited Access:" sdl: field 75 bold font-size 15
text bold "Substitute Slab Depth for Underorder:" sdu: field 75 bold font-size 15
across
btn "Save" [
if id/text = "" [alert "You must enter an id." return]
if find (extract database 12) id/text [
either true = request "Overwrite existing record?" [
remove/part (find database id/text) 12
] [
return
]
]
save %jobdata.txt repend database [id/text nm/text pd/text ow/text
ls/text yo/text yp/text sd/text pt/text ayt/text
rt/text pm/text]
name-list/data: sort (extract copy database 12)
show name-list
show gui
]
btn "Delete" [
if true = request rejoin ["Delete " id/text "?"] [
remove/part (find database id/text) 12
save %jobdata.txt database
do-face clear-button 1
name-list/data: sort (extract copy database 12)
show name-list
show gui
]
]
clear-button: btn "New" [
clear-entries
clear-calcs
show gui
]
calculate-button: btn "Calc" [
my/text: ( to-decimal sd/text) * (10.5)
ut/text: round/to ( 60 / (to-decimal my/text / to-decimal ls/text) ) .1
ttt/text: round ((to-decimal ow/text) * (1.85) + 17 + (to-decimal ut/text) + (to-decimal ayt/text) + (to-decimal rt/text))
ypt/text: round/to (60 / (to-decimal ttt/text) * (to-decimal ls/text)) .01
atr/text: round/to (to-decimal my/text) / (to-decimal ypt/text) .001
otr/text: round/down (to-decimal atr/text)
mtr/text: round (to-decimal atr/text)
ypo/text: round/to ((to-decimal otr/text) * (to-decimal ypt/text)) .1
rto/text: round/to ((to-decimal yo/text) / (to-decimal my/text) * (to-decimal atr/text)) .1
ptm/text: round/to ((to-decimal yp/text) / (to-decimal my/text)) .01
pto/text: round/to ((to-decimal ptm/text) * ((to-decimal atr/text) / (to-decimal otr/text))) .01
bt: probe round ((to-decimal ayt/text) + (to-decimal ow/text) + 9)
at: to-time rejoin [ "00:" (to-string bt) ":00"]
fbs/text: (to-time pt/text) - (to-time at)
ag/text: round/to (((to-decimal atr/text) - (to-decimal otr/text)) * (to-decimal ut/text)) .1
tt/text: round/to ((to-decimal yp/text) / (to-decimal ls/text)) .01
tmw/text: round (((to-decimal mtr/text) - (to-decimal atr/text)) * (to-decimal ptm/text) * 60)
moc/text: round (((to-decimal pto/text) - (to-decimal ptm/text)) * 60)
myp/text: round/to (((to-decimal my/text) / 60) * 3) .1
ttl/text: round/to (((to-decimal ow/text) + (to-decimal ayt/text) + 11 + (to-decimal ut/text)) / (to-decimal ut/text)) .1
atc/text: round/to (((to-decimal ut/text) / ((to-decimal ut/text) + 3)) * (to-decimal atr/text)) .1
tlp/text: round/to (((to-decimal pm/text) * (to-decimal atr/text)) / 60) .1
wa/text: if ((to-decimal rto/text) > (to-decimal atr/text)) [round (((to-decimal rto/text) - (to-decimal atr/text)) * 250000)]
sdl/text: ((to-decimal sd/text) * (to-decimal ut/text)) / ((to-decimal ut/text) + 3)
sdu/text: (to-decimal yo/text) / (to-decimal my/text) * (to-decimal sd/text)
show gui
]] clear-entries: does [ id/text: copy "" nm/text: copy "" pd/text: copy "" ow/text: copy "" ls/text: copy "" rt/text: copy "" yo/text: copy "" yp/text: copy "" sd/text: copy "" pt/text: copy "" ayt/text: copy "" pm/text: copy "" ] clear-calcs: does [ my/text: copy "" ut/text: copy "" ttt/text: copy "" ypt/text: copy "" atr/text: copy "" otr/text: copy "" mtr/text: copy "" ypo/text: copy "" rto/text: copy "" ptm/text: copy "" pto/text: copy "" fbs/text: copy "" ag/text: copy "" tt/text: copy "" tmw/text: copy "" moc/text: copy "" myp/text: copy "" myp/text: copy "" ttl/text: copy "" atc/text: copy "" tlp/text: copy "" wa/text: copy "" sdl/text: copy "" sdu/text: copy "" sdu/text: copy "" ] view center-face gui