# Urgent help needed! unable to locate syntax errors

**URL:** <https://www.ruby-forum.com/t/urgent-help-needed-unable-to-locate-syntax-errors/196104>\
**Category:** Ruby\
**Created:** [October 6, 2010, 9:35pm UTC](https://www.ruby-forum.com/t/urgent-help-needed-unable-to-locate-syntax-errors/196104 "2010-10-06T21:35:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![datulravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c37758/32.png) [@datulravi](https://www.ruby-forum.com/u/datulravi)\
**Post date:** [October 6, 2010, 9:35pm UTC](https://www.ruby-forum.com/t/urgent-help-needed-unable-to-locate-syntax-errors/196104/1 "2010-10-06T21:35:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![datulravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c37758/32.png) [@datulravi](https://www.ruby-forum.com/u/datulravi)\
**Post date:** [October 6, 2010, 10:22pm UTC](https://www.ruby-forum.com/t/urgent-help-needed-unable-to-locate-syntax-errors/196104/2 "2010-10-06T22:22:22Z")

</div>

On Wed, Oct 6, 2010 at 3:35 PM, Atul D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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!

---

<div class="post-metadata">

**Author:** ![datulravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c37758/32.png) [@datulravi](https://www.ruby-forum.com/u/datulravi)\
**Post date:** [October 6, 2010, 10:28pm UTC](https://www.ruby-forum.com/t/urgent-help-needed-unable-to-locate-syntax-errors/196104/3 "2010-10-06T22:28:13Z")

</div>

On Thu, Oct 7, 2010 at 1:05 AM, Atul D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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

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 🙂 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
