- Help with coding by DeAndrea Monroe
- Re: [shoes] Help with coding by i5m
- Re: [shoes] Help with coding by i5m
- Re: [shoes] Help with coding by Steve Klabnik
- Re: [shoes] Help with coding by Devyn Cairns
- Re: [shoes] Help with coding by Satoshi Asakawa
- Re: [shoes] Help with coding by DeAndrea Monroe
- Re: [shoes] Help with coding by i5m
- Re: [shoes] Help with coding by DeAndrea Monroe
- Re: [shoes] Help with coding by i5m
- Re: [shoes] Help with coding by DeAndrea Monroe
- Re: [shoes] Help with coding by DeAndrea Monroe
- Re: [shoes] Help with coding by Steve Klabnik
- Re: [shoes] Help with coding by i5m
- Re: [shoes] Help with coding by DeAndrea Monroe
- Re: [shoes] Help with coding by Steve Klabnik

- From:
- DeAndrea Monroe
- Date:
- 2010-03-24 @ 16:28

Hi, I am having problems with some code I have written. Everytime I run it, I get a blank box. Here is the code: Shoes.app(:title => "Coplanar Points", :width => 550, :height => 400) do @beex = (@betax.text.to_f-@alphax.text.to_f) @beey = (@betay.text.to_f-@alphay.text.to_f) @beez = (@betaz.text.to_f-@alphaz.text.to_f) @ceex = (@gammax.text.to_f-@alphax.text.to_f) @ceey = (@gammay.text.to_f-@alphay.text.to_f) @ceez = (@gammaz.text.to_f-@alphaz.text.to_f) @deex = (@deltax.text.to_f-@alphax.text.to_f) @deey = (@deltax.text.to_f-@alphay.text.to_f) @deez = (@deltax.text.to_f-@alphaz.text.to_f) def calculate ((@beex.text.to_f*((@ceey.text.to_f*@deez.text.to_f)- (@ceez.text.to_f*@deey.text.to_f)))-(@beey.text.to_f* ((@ceex.text.to_f*@deez.text.to_f)- (@ceez.text.to_f*@deex.text.to_f)))+(@beez.text.to_f* ((@ceex.text.to_f*@Dy.text.to_f))- (@ceey.text.to_f*@deex.text.to_f))) end stack(:width => '100%', :margin => 20) do para('Calculate Coplanar Points') para(' x y z') end flow(:width => '100%' ) do para('Point A: ') @alphax = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} @alphay = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} @alphaz = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} end flow(:width => '100%' ) do para('Point B: ') @betax = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} @betay = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} @betaz = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} end flow(:width => '100%' ) do para('Point C: ') @gammax = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} @gammay = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} @gammaz = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} end flow(:width => '100%' ) do para('Point D: ') @deltax = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} @deltay = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} @deltaz = edit_line(:width => 100, height => 35) {@coplanar.text <%7B@coplanar.text> = calculate} @button = button "Configure" do c = calculate==0 case c when true alert("Points are coplanar, equation is") when false alert("Points are NOT coplanar") end end end end Can someone help me try to figure out what's wrong?

- From:
- i5m
- Date:
- 2010-03-24 @ 17:02

Also, forgot to mention, looks like there is a typo in the calculate method: ((@ceex.text.to_f*@Dy.text.to_f))- I've assumed @Dy is meant to be @deey ----------------------- i5m.co.uk GPG Key: 0xA18A602B On Wed, Mar 24, 2010 at 4:28 PM, DeAndrea Monroe <dmonroe4919@gmail.com>wrote: > Hi, I am having problems with some code I have written. Everytime I run it, > I get a blank box. Here is the code: > >

- From:
- i5m
- Date:
- 2010-03-24 @ 16:57

Hi, you get the blank box because you have the list of @beex = (@betax.text.to_f ... defined at the start of the Shoes app, but at this point you haven't created any of the edit_lines to get the "text" from. If you move those lines inside the def calculate method it solves that problem. Did you know you could press "ALT + /" to open up a Shoes console window? If you do that you'd see the error "undefined method 'text' for nil:NilClass" and it even gives you the line number the error occurs on. The next one that occurs is with the calculate method. For instance, you have @beex.text.to_f* ... The ".text.to_f" is not required as you've already done this in calculating @beex. @beex is just a number. See here: http://gist.github.com/339896 ----------------------- i5m.co.uk GPG Key: 0xA18A602B On Wed, Mar 24, 2010 at 4:28 PM, DeAndrea Monroe <dmonroe4919@gmail.com>wrote: > Hi, I am having problems with some code I have written. Everytime I run it, > I get a blank box. Here is the code: > >

- From:
- Steve Klabnik
- Date:
- 2010-03-24 @ 17:42

Hey DeAndrea- It seems like i5m has given you some good advice, I just wanted to point you to either pastebin.org or http://gist.github.com/ . Both are really good tools for sharing code snippets; email tends to screw up the formatting and make it really hard to read. Not that you have to use them... just wanted to let you know such a thing exists! -Steve

- From:
- Devyn Cairns
- Date:
- 2010-03-24 @ 20:24

And, also http://pastie.org/... Gist and Pastie are my faves. On Wed, Mar 24, 2010 at 10:42 AM, Steve Klabnik <steve@steveklabnik.com>wrote: > Hey DeAndrea- > > It seems like i5m has given you some good advice, I just wanted to point > you to either pastebin.org or http://gist.github.com/ . Both are really > good tools for sharing code snippets; email tends to screw up the formatting > and make it really hard to read. > > Not that you have to use them... just wanted to let you know such a thing > exists! > > -Steve > -- ~devyn

- From:
- Satoshi Asakawa
- Date:
- 2010-03-24 @ 22:15

Hi DeAndrea, edit_line with block is cool. I like it. :) Look at a tiny sample snippet: http://shoes-tutorial-note.heroku.com/html/00536_edit_line_with_block.html Hope this helps, ashbb ps. I confirmed i5m's revised code (http://gist.github.com/339896). It works very well. Great! If you add `@coplanar = para` into i5m's code. You can get the result of calculation every time one of the values gets changed. ;-)

- From:
- DeAndrea Monroe
- Date:
- 2010-03-24 @ 22:49

I appreciate all of the help from you guys. I am kind of new to Shoes but it's something I am getting to understand in a class I am taking. I have another question though. If I want to just the numerical value of the method calculate, how would I go about doing that and putting the number into the form of an equation? On Wed, Mar 24, 2010 at 6:15 PM, Satoshi Asakawa <ashbbb@gmail.com> wrote: > Hi DeAndrea, > > edit_line with block is cool. I like it. :) > > Look at a tiny sample snippet: > http://shoes-tutorial-note.heroku.com/html/00536_edit_line_with_block.html > > Hope this helps, > ashbb > > ps. I confirmed i5m's revised code (http://gist.github.com/339896). > It works very well. Great! > If you add `@coplanar = para` into i5m's code. > You can get the result of calculation every time one of the values gets > changed. ;-) > >

- From:
- i5m
- Date:
- 2010-03-25 @ 09:08

DeAndrea, not sure I understand you, do you mean something like this? x = calculate y = 2*x + 5 If so, this is what you are already doing with your @coplanar.text = calculate I'm guessing what you might want to do is redefine the calculate method so you can pass arguments to it: def calculate(alphax, alphay, alphaz, betax, ... and so on) beex = (betax-alphax) .... end Although probably easier to use arrays as arguments: def calculate(alpha, beta, gamma, delta) beex = (beta[0]-alpha[0]) ... end alpha, beta, etc are arrays containing three values, x, y and z. So you could use the method like this alpha = [@alphax.text.to_f, @alphay.text.to_f, @alphaz.text.to_f] ... x = calculate(alpha, beta, gamma, delta) y = 2*x+5 ----------------------- i5m.co.uk GPG Key: 0xA18A602B On Wed, Mar 24, 2010 at 10:49 PM, DeAndrea Monroe <dmonroe4919@gmail.com>wrote: > I appreciate all of the help from you guys. I am kind of new to Shoes but > it's something I am getting to understand in a class I am taking. I have > another question though. If I want to just the numerical value of the method > calculate, how would I go about doing that and putting the number into the > form of an equation? > > > >

- From:
- DeAndrea Monroe
- Date:
- 2010-03-25 @ 14:58

I'm trying to just get the value of what def calculate produces. I know that after it does all of its calculations, it gives out one number. I would like to just get that number and use it in the following sentence: The equation is : "the number from def calculate".

- From:
- i5m
- Date:
- 2010-03-25 @ 15:07

Ok, in this application you probably want to do: def calculate .... all your calculations .... @result = ((@beex*((@ceey*@deez)-.... etc end Then you can use this in an alert or para: para "The equation is #{@result}" ----------------------- i5m.co.uk GPG Key: 0xA18A602B On Thu, Mar 25, 2010 at 2:58 PM, DeAndrea Monroe <dmonroe4919@gmail.com>wrote: > I'm trying to just get the value of what def calculate produces. I know > that after it does all of its calculations, it gives out one number. I would > like to just get that number and use it in the following sentence: The > equation is : "the number from def calculate". >

- From:
- DeAndrea Monroe
- Date:
- 2010-03-25 @ 15:45

Thank you again, that worked perfectly!

- From:
- DeAndrea Monroe
- Date:
- 2010-04-06 @ 20:46

How do you find the square root of a number using shoes?

- From:
- Steve Klabnik
- Date:
- 2010-04-06 @ 20:51

Shoes apps are just Ruby. Math.sqroot() away. On Tue, Apr 6, 2010 at 4:46 PM, DeAndrea Monroe <dmonroe4919@gmail.com>wrote: > How do you find the square root of a number using shoes? >

- From:
- i5m
- Date:
- 2010-04-06 @ 20:54

```
In Ruby, so in Shoes as well, like follows: Math.sqrt(2)
On 6 Apr 2010, at 21:46, DeAndrea Monroe <dmonroe4919@gmail.com> wrote:
> How do you find the square root of a number using shoes?
```

- From:
- DeAndrea Monroe
- Date:
- 2010-04-06 @ 20:55

I'm sorry, I meant the absolute value? On Tue, Apr 6, 2010 at 4:54 PM, i5m <i5ivem@googlemail.com> wrote: > In Ruby, so in Shoes as well, like follows: Math.sqrt(2) > > On 6 Apr 2010, at 21:46, DeAndrea Monroe <dmonroe4919@gmail.com> wrote: > > > How do you find the square root of a number using shoes? >

- From:
- Steve Klabnik
- Date:
- 2010-04-06 @ 20:56

Just use #abs. > -200.abs => 200 On Tue, Apr 6, 2010 at 4:55 PM, DeAndrea Monroe <dmonroe4919@gmail.com>wrote: > I'm sorry, I meant the absolute value? > > > On Tue, Apr 6, 2010 at 4:54 PM, i5m <i5ivem@googlemail.com> wrote: > >> In Ruby, so in Shoes as well, like follows: Math.sqrt(2) >> >> On 6 Apr 2010, at 21:46, DeAndrea Monroe <dmonroe4919@gmail.com> wrote: >> >> > How do you find the square root of a number using shoes? >> > >