#!/usr/bin/wish

set x 232
set y 232

set fp [open "fifo" "w"]

frame .fr1
frame .fr1.un
frame .fr2
frame .fr2.un

label .fr1.un.label -textvariable lab
scale .fr1.un.escala -from 0 -to 463 -showvalue false -length 200 -variable x -orient horizontal \
-command Escala 
label .fr2.un.label -textvariable lab2
scale .fr2.un.escala -from 0 -to 463 -showvalue false -length 200 -variable y -orient horizontal \
-command Escala2

button .fr1.reset -text Reset -command Resetea1
button .fr2.reset -text Reset -command Resetea2

proc Resetea1 { } {
	global x
	set x 232
	Escala 232
}

proc Resetea2 { } {
	global y
	set y 232
	Escala2 232
}

proc Escala { valor } { 
	global lab fp 
	set lab "Input: [ expr floor ( pow(1.01, $valor) * 10 ) / 100 ]"
	puts $fp "I$valor" 
	flush $fp
} 

proc Escala2 { valor } { 
	global lab2 fp 
	set lab2 "Output: [ expr floor ( pow(1.01, $valor) * 10 ) / 100 ]"
	puts $fp "O$valor" 
	flush $fp
} 

canvas .c -width 250 -height 100
set linea [.c create line 0 0 50 0 -fill green -width 10]

pack .fr1.un.label .fr1.un.escala 
pack .fr1.un -side left
pack .fr1.reset -side right 

pack .fr2.un.label .fr2.un.escala 
pack .fr2.un -side left
pack .fr2.reset -side right 

pack .fr1 .fr2 

