On Tue, 29 Jul 2008, Edward Heil wrote:
I can't say whether this is or should be "obvious" but if you move the "def"
inside the Shoes.app do block, it works. :) I don't know the "shoes theory"
behind why it works that way, but that's the way it works. Somebody want to
enlighten us on the logic of that?
I thought that's effectively the scope I was working in when
reopening class shoes.
BTW when you write:
@xentry = edit_line.text.to_i
you mean:
@xentry = edit_line
Yes, well spotted. thanks.
right? :)
this seems to be working now. Thanks.
I don't know if the code will help anyone else, but here it is, fixed.
Hugh
Shoes.app do
def ellipse_equation(x,y,a,b)
if a.zero?
alert "a is zero "
return -1
end
if b.zero?
alert "b is zero "
return -1
end
result = (((x * x) / (a * a)) +
((y * y) / (b * b)));
return result;
end
@x = 0
@y = 0
@a = 1
@b = 1
stack do
flow do
@xentry = edit_line
@xbtn = button("x") do
@x = @xentry.text.to_i
@result.replace(ellipse_equation(@x,@y,@a,@b).to_s)
end
end
flow do
@yentry = edit_line
@ybtn = button("y") do
@y = @yentry.text.to_i
@result.replace(ellipse_equation(@x,@y,@a,@b).to_s)
end
end
flow do
@aentry = edit_line
@abtn = button("a") do
@a = @aentry.text.to_i
@result.replace(ellipse_equation(@x,@y,@a,@b).to_s)
end
end
flow do
@bentry = edit_line
@bbtn = button("b") do
@b = @bentry.text.to_i
@result.replace(ellipse_equation(@x,@y,@a,@b).to_s)
end
end
@result = para(ellipse_equation(@x,@y,@a,@b).to_s)
end
end