Commit 1a1f5173 authored by Rinus Plasmeijer's avatar Rinus Plasmeijer
Browse files

*** empty log message ***

parent ab4bee7b
...@@ -24,15 +24,36 @@ where ...@@ -24,15 +24,36 @@ where
twotasks2 tst twotasks2 tst
# ((tboss,tsecr),tst) = mkLTaskRTC2 "name" 25 tst // split name task # ((tboss,tsecr),tst) = mkLTaskRTC2 "name" 0 tst // split name task
= PTasks = PTasks
[( "employee1", tsecr) // assign name task [( "secretary", tsecr) // assign name task
,( "boss", STask "ervoor" 0 `bind` ,( "boss", STask "Choose" Easy `bind`
\bi -> tboss (STask "DoIt" bi) `bind` \situation -> tboss (handle situation) `bind`
\si -> STask "erna" si \result -> STask "accept" result
) )
] tst ] tst
where
handle Easy tst
# tst = returnF [Txt ("Handle easy case")] tst
= STask "Damage" 0 tst
handle (Difficult upperbound) tst
# tst = returnF [Txt ("Handle difficult case with limit " +++ (toString upperbound) +++ " Euro's")] tst
= checktask upperbound tst
where
checktask limit tst
# (amount,tst) = STask "Damage" 0 tst
| amount > limit
# tst = returnF [Txt ("amount " +++ toString amount +++ " exceeds limit set")] tst
= mkTask (checktask limit) tst
= returnTask amount tst
:: Situation = Difficult Int | Easy
derive gForm Situation
derive gUpd Situation
derive gParse Situation
derive gPrint Situation
derive gerda Situation
:: RecForm = {name :: String, number:: Int} :: RecForm = {name :: String, number:: Int}
......
...@@ -51,17 +51,20 @@ where ...@@ -51,17 +51,20 @@ where
# (boss,hst) = mkStoreForm (Init,sFormId ("bossStore" <+++ mkTaskNr j) initBoss) settask hst # (boss,hst) = mkStoreForm (Init,sFormId ("bossStore" <+++ mkTaskNr j) initBoss) settask hst
# (bdone,encbtask) = boss.value # (bdone,encbtask) = boss.value
# btask = case string_to_dynamic` encbtask of # btask = case string_to_dynamic` encbtask of
(mytask::Task a^) -> mytask (mytask:: *TSt -> *(a^,*TSt)) -> mytask
_ -> STask "Default2" a _ -> STask "Default2" a
= ({boss & value = (bdone,btask)},hst) = ({boss & value = (bdone,btask)},hst)
where where
initBoss = (False,dynamic_to_string (dynamic defaulttask)) initBoss = (False,convertTask defaulttask)
settask = if set (\_ -> (True,dynamic_to_string (dynamic task))) id settask = if set (\_ -> (True,convertTask task)) id
convertTask task = dynamic_to_string (dynamic task::*TSt -> *(a^,*TSt))
string_to_dynamic` s = string_to_dynamic ( {s` \\ s` <-: s}) string_to_dynamic` s = string_to_dynamic ( {s` \\ s` <-: s})
defaulttask = STask "Default" a defaulttask = STask "Default" a
:: *TSt :== (([Int],Bool,[BodyTag]),HSt) // Task State: task nr, has this task to be done?, html code accumulator :: *TSt :== (([Int],Bool,[BodyTag]),HSt) // Task State: task nr, has this task to be done?, html code accumulator
:: Niks = Niks // to make an empty task :: Niks = Niks // to make an empty task
...@@ -316,4 +319,38 @@ where ...@@ -316,4 +319,38 @@ where
# (_,((i,adone,ahtml),hst)) = STask "Done" Niks ((i,True,[]),hst) # (_,((i,adone,ahtml),hst)) = STask "Done" Niks ((i,True,[]),hst)
= (idata.value,((i,adone,html <|.|> if adone idata.form (idata.form <|.|> ahtml)),hst)) = (idata.value,((i,adone,html <|.|> if adone idata.form (idata.form <|.|> ahtml)),hst))
// debugging code
print_graph :: !a -> Bool;
print_graph a = code {
.d 1 0
jsr _print_graph
.o 0 0
pushB TRUE
}
my_dynamic_to_string :: !Dynamic -> {#Char};
my_dynamic_to_string d
| not (print_graph d)
= abort ""
#! s=dynamic_to_string d;
| not (print_graph (tohexstring s))
= abort ""
# d2 = string_to_dynamic {c \\ c <-: s};
| not (print_graph d2)
= abort ""
= s;
tohexstring :: {#Char} -> {#Char};
tohexstring s = {tohexchar s i \\ i<-[0..2*size s-1]};
tohexchar :: {#Char} Int -> Char;
tohexchar s i
# c=((toInt s.[i>>1]) >> ((1-(i bitand 1))<<2)) bitand 15;
| c<10
= toChar (48+c);
= toChar (55+c);
//K:: !x y -> y | iData, TC y
K x y = y
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment