Urgent help needed! unable to locate syntax errors

Please find the txt file for the ruby program attached.

I have the following errors…Please help someone…!

Error Loading File slab.rb
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/slab.rb:408:
syntax error
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/slab.rb:420:
syntax error
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/slab.rb:455:
syntax error

On Wed, Oct 6, 2010 at 3:35 PM, Atul D. [email protected]
wrote:

C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/slab.rb:455:
syntax error

you should learn to read the error message it’s telling you were the
errors are, if you know how to read code this one is pretty easy to
spot!

On Thu, Oct 7, 2010 at 1:05 AM, Atul D. [email protected]
wrote:

Please find the txt file for the ruby program attached.

Your code has a bunch of errors, all of which will need to be fixed.
First, if you try to run it you get the following warnings

slab.rb:148: warning: found = in conditional, should be ==
slab.rb:156: warning: found = in conditional, should be ==
slab.rb:143: warning: found = in conditional, should be ==
slab.rb:251: warning: found = in conditional, should be ==
slab.rb:244: warning: found = in conditional, should be ==
slab.rb:237: warning: found = in conditional, should be ==
slab.rb:230: warning: found = in conditional, should be ==
slab.rb:223: warning: found = in conditional, should be ==
slab.rb:216: warning: found = in conditional, should be ==
slab.rb:208: warning: found = in conditional, should be ==
slab.rb:201: warning: found = in conditional, should be ==
slab.rb:193: warning: found = in conditional, should be ==
slab.rb:274: warning: found = in conditional, should be ==

In ruby, the equality test is ==, not =. So if you say

if (@input_support_type = 2)

you are actually setting the variable to 2, not comparing it to 2.
It should be

if (@input_support_type == 2)

and likewise for all the other places.

Next, why are you doing this:

def analyse #determining if the slab is one-way or two-way and to
proceed accordingly

if (@ly_lx <=2.0)
two_way
else
one_way
end

def one_way

def prompts3

Ruby doesn’t support inner methods; defining a method inside a method
does not do what you think it is doing. I suspect that

(a) you forgot the “end” for “def analyse” (note where a good editor
would have caught that right away, due to the indentation not
returning to zero

and

(b) the “def prompts3” is an attempt to declare the variable before
using it. This is wrong; ruby doesn’t need to declare variables, and
“def” is strictly a method definition keyword.

Fixing those and moving on, the code again breaks at:

@zx_neg = (ia_array[(@input_kx_nve)] - (@temp_xn *
(ia_array[(@input_kx_nve)] - ia_array[((@input_kx_nve).to_i-1)]))* @dx
@zx_pos = (ia_array[(@input_kx_pve)] - (@temp_xp *
(ia_array[(@input_kx_pve)] - ia_array[((@input_kx_pve).to_i-1)]))* @dx
@zy_neg = (ia_array[(@input_ky_nve)] - (@temp_yn

  • (ia_array[(@input_ky_nve)] - ia_array[((@input_ky_nve).to_i-1)]))*
    @dy
    @zy_pos = (ia_array[(@input_ky_pve)]
  • (@temp_yp * (ia_array[(@input_ky_pve)] -
    ia_array[((@input_ky_pve).to_i-1)]))* @dy

                                          # To calculate the
    

required area of steel (sq.mm/m)

                                        @ast_x_neg =

((@mx_neg/(0.87 * fyk * @zx_neg)) < @as_min) ? @as_min :@mx_neg/(0.87

  • fyk * @zx_neg)

You can see by the way the indentation is creeping right that you
haven’t closed all your brackets. I don’t blame you, those formulae
are confusing to read :slight_smile: I suggest that you define auxiliary variables
first

xnve = ia_array[@input_kx_nve]
xnve1= ia_array[@input_kx_nve - 1]
xpve = ia_array[@input_kx_pve]
xpve1= ia_array[@input_kx_pve - 1]

etc

and then rewrite the equations in terms of those. They’ll be much
clearer to read and you can see where the missing brackets are (I
couldn’t right away!)

martin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs