# budilnik
if $ARGS[0]='start':
cla
clr
gs'stat'
'<center><img src="pic/bed2.jpg" ></center>'
*nl
*nl
if numbud = 4:'<center><B><<bud1>><<bud2>> : <<bud3>><<bud4>></B></center>'
if numbud = 3:'<center><B><<bud1>><<bud2>> : <<bud3>></B><<bud4>></center>'
if numbud = 2:'<center><B><<bud1>><<bud2>></B> : <<bud3>><<bud4>></center>'
if numbud = 1:'<center><B><<bud1>></B><<bud2>> : <<bud3>><<bud4>></center>'
if numbud = 0:'<center><<bud1>><<bud2>> : <<bud3>><<bud4>></center>'
*nl
'<center><B><a href="exec:GT ''budilnik'',''1''">1</a>   <a href="exec:GT ''budilnik'',''2''">2</a>   <a href="exec:GT ''budilnik'',''3''">3</a></B></center>'
'<center><B><a href="exec:GT ''budilnik'',''4''">4</a>   <a href="exec:GT ''budilnik'',''5''">5</a>   <a href="exec:GT ''budilnik'',''6''">6</a></B></center>'
'<center><B><a href="exec:GT ''budilnik'',''7''">7</a>   <a href="exec:GT ''budilnik'',''8''">8</a>   <a href="exec:GT ''budilnik'',''9''">9</a></B></center>'
'<center><B><a href="exec:GT ''budilnik'',''0''">0</a></B></center>'
'<center><B><a href="exec:GT ''budilnik'',''reset''">reset</a>    <a href="exec:GT ''budilnik'',''time''">Set time</a></B></center>'
     act 'put Service':
     cla
     set bud1 = 0
     set bud2 = 0
     set bud3 = 0
     set bud4 = 0
     set numbud = 0
     gt'budilnik','fin'
     end
end

if $ARGS[0]='time':
cla
if bud1 > 0:
set timer = bud1*10
set timer = timer + bud2
end
if bud2 > 0 and bud1 = 0:
set timer = bud2
end
if bud3 > 0:
set timerM = bud3*10
set timerM = timerM + bud4
end
if bud4 > 0 and bud3 = 0:
set timerM = bud4
end
if timer > 23:set timer = 0
if timerM > 60:set timerM = 0

'Service on the wound <<timer>> hours, <<timerM>> minutes.'

     act 'Service put in place':
     cla
     gt'budilnik','fin'
     end
end


if $ARGS[0]='1':
cla
     if numbud = 4:
     end
     if numbud = 3:set bud4 = 1&set numbud = 4
     if numbud = 2:set bud3 = 1&set numbud = 3
     if numbud = 1:set bud2 = 1&set numbud = 2
     if numbud = 0:set bud1 = 1&set numbud = 1
gt'budilnik','start'
end

if $ARGS[0]='2':
cla
     if numbud = 4:
     end
     if numbud = 3:set bud4 = 2&set numbud = 4
     if numbud = 2:set bud3 = 2&set numbud = 3
     if numbud = 1:set bud2 = 2&set numbud = 2
     if numbud = 0:set bud1 = 2&set numbud = 1
gt'budilnik','start'
end

if $ARGS[0]='3':
cla
     if numbud = 4:
     end
     if numbud = 3:set bud4 = 3&set numbud = 4
     if numbud = 2:set bud3 = 3&set numbud = 3
     if numbud = 1:set bud2 = 3&set numbud = 2
     if numbud = 0:set bud1 = 3&set numbud = 1
gt'budilnik','start'
end

if $ARGS[0]='4':
cla
     if numbud = 4:
     end
     if numbud = 3:set bud4 = 4&set numbud = 4
     if numbud = 2:set bud3 = 4&set numbud = 3
     if numbud = 1:set bud2 = 4&set numbud = 2
     if numbud = 0:set bud1 = 4&set numbud = 1
gt'budilnik','start'
end

if $ARGS[0]='5':
cla
     if numbud = 4:
     end
     if numbud = 3:set bud4 = 5&set numbud = 4
     if numbud = 2:set bud3 = 5&set numbud = 3
     if numbud = 1:set bud2 = 5&set numbud = 2
     if numbud = 0:set bud1 = 5&set numbud = 1
gt'budilnik','start'
end

if $ARGS[0]='6':
cla
     if numbud = 4:
     end
     if numbud = 3:set bud4 = 6&set numbud = 4
     if numbud = 2:set bud3 = 6&set numbud = 3
     if numbud = 1:set bud2 = 6&set numbud = 2
     if numbud = 0:set bud1 = 6&set numbud = 1
gt'budilnik','start'
end

if $ARGS[0]='7':
cla
     if numbud = 4:
     end
     if numbud = 3:set bud4 = 7&set numbud = 4
     if numbud = 2:set bud3 = 7&set numbud = 3
     if numbud = 1:set bud2 = 7&set numbud = 2
     if numbud = 0:set bud1 = 7&set numbud = 1
gt'budilnik','start'
end

if $ARGS[0]='8':
cla
     if numbud = 4:
     end
     if numbud = 3:set bud4 = 8&set numbud = 4
     if numbud = 2:set bud3 = 8&set numbud = 3
     if numbud = 1:set bud2 = 8&set numbud = 2
     if numbud = 0:set bud1 = 8&set numbud = 1
gt'budilnik','start'
end

if $ARGS[0]='9':
cla
     if numbud = 4:
     end
     if numbud = 3:set bud4 = 9&set numbud = 4
     if numbud = 2:set bud3 = 9&set numbud = 3
     if numbud = 1:set bud2 = 9&set numbud = 2
     if numbud = 0:set bud1 = 9&set numbud = 1
gt'budilnik','start'
end

if $ARGS[0]='0':
cla
     if numbud = 4:
     end
     if numbud = 3:set bud4 = 0&set numbud = 4
     if numbud = 2:set bud3 = 0&set numbud = 3
     if numbud = 1:set bud2 = 0&set numbud = 2
     if numbud = 0:set bud1 = 0&set numbud = 1
gt'budilnik','start'
end

if $ARGS[0]='reset':
cla
set bud1 = 0
set bud2 = 0
set bud3 = 0
set bud4 = 0
set numbud = 0
gt'budilnik','start'
end


if $ARGS[0]='fin':
cla
gt $locM, $metkaM
     !'if housr = 1 and housrA = 1:
     set housrA = 0
     gt'bedr'
     end'
end
--- budilnik ---------------------------------

