[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Unspecified Syntax Error

StarLion

12/9/2005 9:36:00 PM


def MakeBoard
rcount = 0
puts "Push enter, then begin input. (For Input Format Compliance, extra
enter key is necessary)"
gets
board = [0,0,0,0,0,0,0,0,0]
9.times do
instr = gets
board[rcount] =
[instr[0],instr[1],instr[2],instr[3],instr[4],instr[5],instr[6],instr[7],instr[8]]
rcount += 1
end
return board
end

def CheckBoard(board)
complete = 1 #Is the puzzle complete?
problems = 0 #Are there any problems?

#first, rows.
h = 0
9.times do
g = 0
group = [0,0,0,0,0,0,0,0,0]
9.times do
if board[h][g] == "."
group[g] = 0
complete = 0
else
group[g] = board[h][g]
end
end
problems = VerifyGroup(group)

#puts "Row " + h.to_s + " Problems? " + problems.to_s
end
#end Row Check

#next, columns.
h = 0
9.times do
g = 0
group = [0,0,0,0,0,0,0,0,0]
9.times do
if board[g][h] == "."
group[g] = 0
complete = 0
else
group[g] = board[g][h]
end
end
problems = VerifyGroup(group)
#puts "Col " + h.to_s + " Problems? " + problems.to_s
end
##end Col Check

##Finally, the tricky one... the Boxes..
startx = 0
starty = 0
curx = 0
cury = 0
count = 0
group = [0,0,0,0,0,0,0,0,0]
3.times do #Row Blocks
3.times do #Cols Blocks
3.times do #Rows of Block
3.times do #Cols of Block
if board[curx][cury] == "."
group[count] = 0
else
group[count] = board[curx][cury]
end
curx += 1
end
curx = startx
cury += 1
end #We now have a 3x3 block. Verify Data.
problems = VerifyGroup(group)
#puts "Box " + startx.to_s + "," + starty.to_s + " Problems? " +
problems.to_s
count = 0
startx += 3
cury = starty
curx = startx
end
starty += 3
startx = 0
cury = starty
curx = startx
end

#Resolve the output.
if problems == 0
if complete == 1
$output = $output + "You've done it!\n"
else
$output = $output + "Looking good so far...\n"
end
else
$output = $output + "You've got a problem.\n"
end
end #FINALLY!

def VerifyGroup(group)
#logic for Check
flag = 0
check = [0,0,0,0,0,0,0,0,0,0]
group.each do |num|
if check[num] == 0 && num != 0
check[num] = 1
else if num == 0
check[0] = 0
else
flag = 1
end
num += 1
end
return flag
end


$output = ""
n = gets
n.to_i.times do
board = MakeBoard()
CheckBoard(board)
puts $output
end


Throws unspecified "Syntax Error" on 126 (last line of the code -
'end')... no idea what's going wrong?

--
Posted via http://www.ruby-....


12 Answers

konsu

12/9/2005 9:39:00 PM

0

this is what i see:

c:/r2.rb:11: syntax error
[instr[0],instr[1],instr[2],instr[3],instr[4],instr[5],instr[6],instr[7],in¡str[8]]

^
c:/r2.rb:11: Invalid char `\255' in expression
c:/r2.rb:11: syntax error
[instr[0],instr[1],instr[2],instr[3],instr[4],instr[5],instr[6],instr[7],in¡str[8]]

^
c:/r2.rb:136: syntax error

James Gray

12/9/2005 9:47:00 PM

0

On Dec 9, 2005, at 3:35 PM, StarLion wrote:

> Throws unspecified "Syntax Error" on 126 (last line of the code -
> 'end')... no idea what's going wrong?

In my experience, this is almost always the sign of a missing "end".
If I add one to the bottom of your code, if does indeed go away. I
can't see where exactly it's missing though. Try cleaning up your
indentation, then it should be obvious.

James Edward Gray II


StarLion

12/9/2005 9:49:00 PM

0

akonsu wrote:
> this is what i see:
>
> c:/r2.rb:11: syntax error
> [instr[0],instr[1],instr[2],instr[3],instr[4],instr[5],instr[6],instr[7],in�str[8]]
>
> ^
> c:/r2.rb:11: Invalid char `\255' in expression
> c:/r2.rb:11: syntax error
> [instr[0],instr[1],instr[2],instr[3],instr[4],instr[5],instr[6],instr[7],in�str[8]]
>
> ^
> c:/r2.rb:136: syntax error

That doesnt appear when i try to execute... there is no \255 character
where it says there is one. Maybe it's because you're copying off of the
MB?

--
Posted via http://www.ruby-....


Matthew Desmarais

12/9/2005 9:54:00 PM

0

StarLion wrote:

>def MakeBoard
> rcount = 0
> puts "Push enter, then begin input. (For Input Format Compliance, extra
>enter key is necessary)"
> gets
> board = [0,0,0,0,0,0,0,0,0]
> 9.times do
> instr = gets
> board[rcount] =
>[instr[0],instr[1],instr[2],instr[3],instr[4],instr[5],instr[6],instr[7],instr[8]]
> rcount += 1
> end
> return board
>end
>
>def CheckBoard(board)
> complete = 1 #Is the puzzle complete?
> problems = 0 #Are there any problems?
>
> #first, rows.
> h = 0
> 9.times do
> g = 0
> group = [0,0,0,0,0,0,0,0,0]
> 9.times do
> if board[h][g] == "."
> group[g] = 0
> complete = 0
> else
> group[g] = board[h][g]
> end
> end
> problems = VerifyGroup(group)
>
> #puts "Row " + h.to_s + " Problems? " + problems.to_s
>end
> #end Row Check
>
> #next, columns.
> h = 0
> 9.times do
> g = 0
> group = [0,0,0,0,0,0,0,0,0]
> 9.times do
> if board[g][h] == "."
> group[g] = 0
> complete = 0
> else
> group[g] = board[g][h]
> end
> end
> problems = VerifyGroup(group)
> #puts "Col " + h.to_s + " Problems? " + problems.to_s
> end
> ##end Col Check
>
> ##Finally, the tricky one... the Boxes..
> startx = 0
> starty = 0
> curx = 0
> cury = 0
> count = 0
> group = [0,0,0,0,0,0,0,0,0]
> 3.times do #Row Blocks
> 3.times do #Cols Blocks
> 3.times do #Rows of Block
> 3.times do #Cols of Block
> if board[curx][cury] == "."
> group[count] = 0
> else
> group[count] = board[curx][cury]
> end
> curx += 1
> end
> curx = startx
> cury += 1
> end #We now have a 3x3 block. Verify Data.
> problems = VerifyGroup(group)
> #puts "Box " + startx.to_s + "," + starty.to_s + " Problems? " +
>problems.to_s
> count = 0
> startx += 3
> cury = starty
> curx = startx
> end
> starty += 3
> startx = 0
> cury = starty
> curx = startx
> end
>
>#Resolve the output.
>if problems == 0
> if complete == 1
> $output = $output + "You've done it!\n"
> else
> $output = $output + "Looking good so far...\n"
> end
>else
> $output = $output + "You've got a problem.\n"
>end
>end #FINALLY!
>
>def VerifyGroup(group)
> #logic for Check
> flag = 0
> check = [0,0,0,0,0,0,0,0,0,0]
> group.each do |num|
> if check[num] == 0 && num != 0
> check[num] = 1
> else if num == 0
> check[0] = 0
> else
> flag = 1
> end
> num += 1
> end
> return flag
>end
>
>
>$output = ""
>n = gets
>n.to_i.times do
>board = MakeBoard()
>CheckBoard(board)
>puts $output
>end
>
>
>Throws unspecified "Syntax Error" on 126 (last line of the code -
>'end')... no idea what's going wrong?
>
>
Hi -

For starters, you're gonna want to replace "else if" with "elsif". The
"else if" starts a second if, so using "else if" will leave you one
"end" short. That'll get you a syntax error for sure.

Regards,
Matthew J Desmarais



Todd

12/9/2005 9:57:00 PM

0

StarLion wrote:
> else if num == 0

This should be:

elsif num == 0

I haven't looked at the rest of the syntax, though, but I hope that
helps.

Todd

StarLion

12/9/2005 10:12:00 PM

0


>>
> Hi -
>
> For starters, you're gonna want to replace "else if" with "elsif". The
> "else if" starts a second if, so using "else if" will leave you one
> "end" short. That'll get you a syntax error for sure.
>
> Regards,
> Matthew J Desmarais

That.. would do it, thanks. Now i just have to figure out my logic
errors >_<

--
Posted via http://www.ruby-....


BUSH BLOWS

6/22/2007 11:31:00 PM

0


"Jim Alder" <jimalder@ssnet.com> wrote in message
news:Xns9957B564C3463jimaldersssnetcom@216.196.97.142...
> "Drunk Fag Bush" <Drunk Bush@Crawfordl.net> wrote in news:DFTei.21384
> $C96.19768@newssvr23.news.prodigy.net:
>
>> "There has not been any serious disagreement about the program that the
>> president has confirmed."
>> -- Attorney General Alberto Gonzales, 2/6/06
>>
>> http://capweb.democracyinaction.org/dia/track.jsp?key=272043654&...
> &url=http%3A%2F%2Fwww.washingtonpost.com%2Fwp-dyn%2Fcontent%2Farticle%2F2006%
> 2F02%2F06%2FAR2006020601001.html
>>
>> VERSUS
>
> A different viewpoint with a year and a half of hindsight.
>
> Big whoop.

You call it flip-flopping when Dems are involved.
Republicans- Party of Hypocrites.


Jim Alder

6/23/2007 1:36:00 AM

0

"Drunk Asahole" <Drunk Bush@Crawfordl.net> wrote in news:6ZYei.17535$y_7.9671
@newssvr27.news.prodigy.net:

> "Jim Alder" <jimalder@ssnet.com> wrote...
>> "Drunk Fag" <Drunk Bush@Crawfordl.net> wrote:
>>
>>> "There has not been any serious disagreement about the program that the
>>> president has confirmed."
>>> -- Attorney General Alberto Gonzales, 2/6/06
>>>
>>> http://capweb.democracyinaction.org/dia/track.jsp?key=272043654&...
>>> &url=http%3A%2F%2Fwww.washingtonpost.com%2Fwp-dyn%2Fcontent%2Farticle%
2F200
>>> 6% 2F02%2F06%2FAR2006020601001.html
>>>
>>> VERSUS
>>
>> A different viewpoint with a year and a half of hindsight.
>>
>> Big whoop.
>
> You call it flip-flopping when Dems are involved.

No, drunk asshole. I call it a flip flop when THE SAME PERSON says one
thing or takes one side of an argument, then says the opposite, sometimes in
the same sentence.

"I am, you know, adamantly against illegal immigrants," Hillary Clinton
said in a Feb. 2003 radio interview.

vs

Mrs. Clinton urged the U.S. to create "a path to earned citizenship for
those who are here, working hard, paying taxes [and] respecting the law"
Wednesday.

> Republicans - Party of Hypocrites.

Democretins; the party of nincompoops.

--
President Bush was so buoyed by the warm reception he was given in Albania
that he immediately gave all 3 million Albanians American citizenship,
provided they learn Spanish. - Ann Coulter

BUSH BLOWS

6/23/2007 1:40:00 AM

0


"Jim Alder" <jimalder@ssnet.com> wrote in message
news:Xns9957DBCF7316Ejimaldersssnetcom@216.196.97.142...
> "Drunk Asahole" <Drunk Bush@Crawfordl.net> wrote in
> news:6ZYei.17535$y_7.9671
> @newssvr27.news.prodigy.net:
>
>> "Jim Alder" <jimalder@ssnet.com> wrote...
>>> "Drunk Fag" <Drunk Bush@Crawfordl.net> wrote:
>>>
>>>> "There has not been any serious disagreement about the program that the
>>>> president has confirmed."
>>>> -- Attorney General Alberto Gonzales, 2/6/06
>>>>
>>>> http://capweb.democracyinaction.org/dia/track.jsp?key=272043654&...
>>>> &url=http%3A%2F%2Fwww.washingtonpost.com%2Fwp-dyn%2Fcontent%2Farticle%
> 2F200
>>>> 6% 2F02%2F06%2FAR2006020601001.html
>>>>
>>>> VERSUS
>>>
>>> A different viewpoint with a year and a half of hindsight.
>>>
>>> Big whoop.
>>
>> You call it flip-flopping when Dems are involved.
>
> No, drunk asshole. I call it a flip flop when THE SAME PERSON says one
> thing or takes one side of an argument, then says the opposite, sometimes
> in
> the same sentence.

Just like you republicans, flip-flop, flip-flop, flip-flop.


Jim Alder

6/23/2007 1:55:00 AM

0

"Drunk Asahole Bush" <Drunk Bush@Crawfordl.net> wrote in news:HR_ei.16255
$RX.8136@newssvr11.news.prodigy.net:

>
> "Jim Alder" <jimalder@ssnet.com> wrote in message
> news:Xns9957DBCF7316Ejimaldersssnetcom@216.196.97.142...
>> "Drunk Asahole" <Drunk Bush@Crawfordl.net> wrote in
>> news:6ZYei.17535$y_7.9671 @newssvr27.news.prodigy.net:
>>
>>> "Jim Alder" <jimalder@ssnet.com> wrote...
>>>> "Drunk Fag" <Drunk Bush@Crawfordl.net> wrote:
>>>>
>>>>> "There has not been any serious disagreement about the program that the
>>>>> president has confirmed."
>>>>> -- Attorney General Alberto Gonzales, 2/6/06
>>>>>
>>>>> http://capweb.democracyinaction.org/dia/track.jsp?key=272043654&am...
89
>>>>> &url=http%3A%2F%2Fwww.washingtonpost.com%2Fwp-dyn%2Fcontent%2Farticle%
>>>>> 2F200 6% 2F02%2F06%2FAR2006020601001.html
>>>>>
>>>>> VERSUS
>>>>
>>>> A different viewpoint with a year and a half of hindsight.
>>>>
>>>> Big whoop.
>>>
>>> You call it flip-flopping when Dems are involved.
>>
>> No, drunk asshole. I call it a flip flop when THE SAME PERSON says one
>> thing or takes one side of an argument, then says the opposite, sometimes
in
>> the same sentence.
>
> Just like you republicans, flip-flop, flip-flop, flip-flop.

At least you can brag of being a consistent moron.

--
President Bush was so buoyed by the warm reception he was given in Albania
that he immediately gave all 3 million Albanians American citizenship,
provided they learn Spanish. - Ann Coulter