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?
BTW when you write:
@xentry = edit_line.text.to_i
you mean:
@xentry = edit_line
right? :)
On Jul 29, 2008, at 9:45 AM, Hugh Sasse wrote:
I've been writing something to help me check my ellipse related
calculations. I think the code should be fairly straightforward,
but if I leave it as it is, it just crashes. If I delete the
line "class Shoes" and the corresponding "end" (i.e move
ellipse_equation
into Object (the default namespace) then I get a window with no
controls. Have I missed something obvious?
Thank you,
Hugh
class Shoes
def ellipse_equation(x,y,a,b)
raise "a is zero " if a.zero?
raise "b is zero " if b.zero?
result = (((x * x) / (a * a)) +
((y * y) / (b * b)));
return result;
end
end
Shoes.app do
@x = 0
@y = 0
@a = 1
@b = 1
stack do
flow do
@xentry = edit_line.text.to_i
@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.text.to_i
@ybtn = button("x") do
@y = @yentry.text.to_i
@result.replace(ellipse_equation(@x,@y,@a,@b).to_s)
end
end
flow do
@aentry = edit_line.text.to_i
@abtn = button("x") do
@a = @aentry.text.to_i
@result.replace(ellipse_equation(@x,@y,@a,@b).to_s)
end
end
flow do
@bentry = edit_line.text.to_i
@bbtn = button("x") 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