elseif problem

S

simonced

Hello.

I have a complie error on this simple code :

#si c'est un caractere ?
if char=~/\w|\s/i then
@buffer+=char
@position+=1

else if id==14 then
#backSpace
@buffer=@buffer[[email protected]]
@position-=1

else
puts "caractere non reconnu : #{id}"

end

I really don't get why.
Any Idea ?

Thanks by advance.
 
R

Robert Klemme

simonced said:
Hello.

I have a complie error on this simple code :

#si c'est un caractere ?
if char=~/\w|\s/i then
@buffer+=char
@position+=1

else if id==14 then
#backSpace
@buffer=@buffer[[email protected]]
@position-=1

else
puts "caractere non reconnu : #{id}"

end

Use "elsif" or "case"

case
when /\w|\s/i =~ char
then
...
when id == 14
then
...
else
...
end

Regards

robert
 
S

simonced

Robert Klemme viết :
simonced said:
Hello.

I have a complie error on this simple code :

#si c'est un caractere ?
if char=~/\w|\s/i then
@buffer+=char
@position+=1

else if id==14 then
#backSpace
@buffer=@buffer[[email protected]]
@position-=1

else
puts "caractere non reconnu : #{id}"

end

Use "elsif" or "case"

case
when /\w|\s/i =~ char
then
...
when id == 14
then
...
else
...
end

Regards

robert

elseif if not working, I don't understand why, that's why I also tried
"else if".
but case is working fine. I just didn't know we could make tests with
when oher than === (that's described in my reference book).

thanks for all this help, I can go on now.
Regards.

ced.
 
A

Alec Ross

In message said:
Hello.

I have a complie error on this simple code :

#si c'est un caractere ?
if char=~/\w|\s/i then
@buffer+=char
@position+=1

else if id==14 then
#backSpace
@buffer=@buffer[[email protected]]
@position-=1

else
puts "caractere non reconnu : #{id}"

end

Use "elsif" or "case"

case
when /\w|\s/i =~ char
then
...
when id == 14
then
...
else
...
end

Regards

robert

elseif if not working, I don't understand why, that's why I also tried
no --^ 'e' here. Fixes the problem. No?
 
E

Erik Veenstra

if char=~/\w|\s/i then
@buffer+=char
@position+=1

else if id==14 then
#backSpace
@buffer=@buffer[[email protected]]
@position-=1

else
puts "caractere non reconnu : #{id}"

end

Proper indentation will get you a clue:

if char=~/\w|\s/i then
@buffer+=char
@position+=1

else if id==14 then
#backSpace
@buffer=@buffer[[email protected]]
@position-=1

else
puts "caractere non reconnu : #{id}"

end

Your are missing one end statement at the end...

gegroet,
Erik V. - http://www.erikveen.dds.nl/
 
S

simonced

you're great !
elsif !!! it's cool! I don't get why my reference book didn't explin
it...
and with good indent I could also have the clue;)

thank you very much.

Erik Veenstra viết :
if char=~/\w|\s/i then
@buffer+=char
@position+=1

else if id==14 then
#backSpace
@buffer=@buffer[[email protected]]
@position-=1

else
puts "caractere non reconnu : #{id}"

end

Proper indentation will get you a clue:

if char=~/\w|\s/i then
@buffer+=char
@position+=1

else if id==14 then
#backSpace
@buffer=@buffer[[email protected]]
@position-=1

else
puts "caractere non reconnu : #{id}"

end

Your are missing one end statement at the end...

gegroet,
Erik V. - http://www.erikveen.dds.nl/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top