[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

irb freaks out over a case stmt...

dave rose

9/15/2006 6:01:00 PM

i'm writing a method within the Akill class that cascades down 2 sql
stmts inside some if and when stmts....but i get this when i added the
last branch of if stmts: what happened note : ALL 'end' stmts are
properly matched
>> class Akill
>> def getusd(prem,cust,serv,scat,readit)
>> cursor=@@conn.exec("<<a working sql stmt here>>>")
>> k=Array.new
>> while r=cursor.fetch() and k.size<3
>> k.push(r)
>> end
>> cursor.close
>> if k.size>0
>> k.first
>> else
?> cursor=@@conn.exec("<<a working sql stmt here>>>")
>> k=Array.new
>> while r=cursor.fetch() and k.size<3
>> k.push(r)
>> end
>> cursor.close
>> if k.size>0
>> k.first
>> else
?> #get defaults of kwd=0,kvar=700,kwh=1500
?> #else nil
?> case scat
>> when scat=='KWH' 1500
>>
Display all 459 possibilities? (y or n)
== SecurityError
=== Signal
=~ SignalException
ARGF SimpleDelegater
ARGV SimpleDelegator
Akill SingleForwardable
ArgumentError SizedQueue
Array StandardError
BEGIN String
Bignum Struct
Binding Symbol
CROSS_COMPILING SyntaxError
Class SystemCallError
Comparable SystemExit
ConditionVariable SystemStackError
Config TOPLEVEL_BINDING
Continuation TRUE
Data Tempfile
Date Thread
DateTime ThreadError
DelegateClass ThreadGroup
Delegater Time
Delegator TrueClass
--Mor>> scat=='KVAR' 700
>>
Display all 459 possibilities? (y or n)
== SecurityError
=== Signal
=~ SignalException
ARGF SimpleDelegater
ARGV SimpleDelegator
Akill SingleForwardable
ArgumentError SizedQueue
Array StandardError
BEGIN String
Bignum Struct
Binding Symbol
CROSS_COMPILING SyntaxError
Class SystemCallError
Comparable SystemExit
ConditionVariable SystemStackError
Config TOPLEVEL_BINDING
Continuation TRUE
Data Tempfile
Date Thread
DateTime ThreadError
DelegateClass ThreadGroup
Delegater Time
Delegator TrueClass
--Mor>> scat=='KWD' 0
>>
Display all 459 possibilities? (y or n)
== SecurityError
=== Signal
=~ SignalException
ARGF SimpleDelegater
ARGV SimpleDelegator
Akill SingleForwardable
ArgumentError SizedQueue
Array StandardError
BEGIN String
Bignum Struct
Binding Symbol
CROSS_COMPILING SyntaxError
Class SystemCallError
Comparable SystemExit
ConditionVariable SystemStackError
Config TOPLEVEL_BINDING
Continuation TRUE
Data Tempfile
Date Thread
DateTime ThreadError
DelegateClass ThreadGroup
Delegater Time
Delegator TrueClass
--MorDir TypeError
END UnboundMethod
ENV VERSION
EOFError Win32API
Enumerable ZeroDivisionError
Errno _
Exception __id__
Exception2MessageMapper __send__
FALSE `
FalseClass abort
File alias
FileTest and
Fixnum at_exit
Float autoload
FloatDomainError autoload?
Forwardable begin
GC binding
Gem bindings
Hash block_given?
IO break
IOError callcc
IRB caller
IndexError case
--More--Integer catch
--More--Interrupt cb
Kconv chomp
Kernel chomp!
LoadError chop
LocalJumpError chop!
Marshal chws
MatchData class
MatchingData clone
Math conf
Method context
Module cws
Mutex cwws
NIL def
NameError defined
NilClass display
NoMemoryError do
NoMethodError dup
NotImplementedError else
Numeric elsif
OCI8 end
OCIBind ensure
OCIBreak eql?
OCIContinue equal?
--More-->> d
>> end
>> end
>> end
>> end
>> end
SyntaxError: compile error
(irb):182: syntax error
(irb):183: syntax error
(irb):184: syntax error
(irb):190: syntax error
from (irb):190
from ?:0
>>

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

10 Answers

Ryan Davis

9/15/2006 7:58:00 PM

0


On Sep 15, 2006, at 11:00 AM, Dave Rose wrote:

> i'm writing a method within the Akill class that cascades down 2 sql
> stmts inside some if and when stmts....but i get this when i added the
> last branch of if stmts: what happened note : ALL 'end' stmts are
> properly matched
>>> class Akill
>>> def getusd(prem,cust,serv,scat,readit)
>>> cursor=@@conn.exec("<<a working sql stmt here>>>")
>>> k=Array.new
>>> while r=cursor.fetch() and k.size<3
>>> k.push(r)
>>> end
>>> cursor.close
>>> if k.size>0
>>> k.first
>>> else
> ?> cursor=@@conn.exec("<<a working sql stmt here>>>")
>>> k=Array.new
>>> while r=cursor.fetch() and k.size<3
>>> k.push(r)
>>> end
>>> cursor.close
>>> if k.size>0
>>> k.first
>>> else
> ?> #get defaults of kwd=0,kvar=700,kwh=1500
> ?> #else nil
> ?> case scat
>>> when scat=='KWH' 1500
>>>
> Display all 459 possibilities? (y or n)

I can't even tell what you are trying to do / write. It looks like
"freak out" in your world means "respond with everything when I hit
tab in a place without context" which is exactly what it should do.
If not, I suggest turning off tab completion first and trying again.

But beyond that, I still can't tell what you are trying to write. If
it is something like:

case scat
when scat == 'KWH' 1500
scat=='KVAR' 700
scat=='KWD' 0
end

then yup. You're going to get a syntax error as you did in your email
and that has nothing to do with IRB. Try it just using ruby -c -e
'...code...' for example to see. GIGO. See http://www.zens...
Languages/Ruby/QuickRef.html#23 for examples of how to write properly
formed case statements.


Ken Bloom

9/15/2006 9:27:00 PM

0

On Sat, 16 Sep 2006 04:58:12 +0900, Ryan Davis wrote:

> On Sep 15, 2006, at 11:00 AM, Dave Rose wrote:
>
>> i'm writing a method within the Akill class that cascades down 2 sql
>> stmts inside some if and when stmts....but i get this when i added the
>> last branch of if stmts: what happened note : ALL 'end' stmts are
>> properly matched
>>>> class Akill
>>>> def getusd(prem,cust,serv,scat,readit)
>>>> cursor=@@conn.exec("<<a working sql stmt here>>>")
>>>> k=Array.new
>>>> while r=cursor.fetch() and k.size<3
>>>> k.push(r)
>>>> end
>>>> cursor.close
>>>> if k.size>0
>>>> k.first
>>>> else
>> ?> cursor=@@conn.exec("<<a working sql stmt here>>>")
>>>> k=Array.new
>>>> while r=cursor.fetch() and k.size<3
>>>> k.push(r)
>>>> end
>>>> cursor.close
>>>> if k.size>0
>>>> k.first
>>>> else
>> ?> #get defaults of kwd=0,kvar=700,kwh=1500
>> ?> #else nil
>> ?> case scat
>>>> when scat=='KWH' 1500
>>>>
>> Display all 459 possibilities? (y or n)
>
> I can't even tell what you are trying to do / write. It looks like
> "freak out" in your world means "respond with everything when I hit
> tab in a place without context" which is exactly what it should do.
> If not, I suggest turning off tab completion first and trying again.

How do you turn off tab completion in IRB?

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...

dave rose

9/15/2006 9:51:00 PM

0

Ken Bloom wrote:
> On Sat, 16 Sep 2006 04:58:12 +0900, Ryan Davis wrote:
>
>>>>> while r=cursor.fetch() and k.size<3
>>>>> end
>>
>> I can't even tell what you are trying to do / write. It looks like
>> "freak out" in your world means "respond with everything when I hit
>> tab in a place without context" which is exactly what it should do.
>> If not, I suggest turning off tab completion first and trying again.
>
> yes,,...>>>>How do you turn off tab completion in IRB?
...how do turn off the tab because that was the case (sort of speak)
i mean i use sciteK editor the comes with the one-click installer and i
guess i puts a tab in there somewhere but i don't know how?

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

x1

9/16/2006 3:02:00 AM

0

in scite, just hit F5 to execute the app/script.. no need to past to
irb (assuming that's what you're doing

On 9/15/06, Dave Rose <bitdoger2@yahoo.com> wrote:
> Ken Bloom wrote:
> > On Sat, 16 Sep 2006 04:58:12 +0900, Ryan Davis wrote:
> >
> >>>>> while r=cursor.fetch() and k.size<3
> >>>>> end
> >>
> >> I can't even tell what you are trying to do / write. It looks like
> >> "freak out" in your world means "respond with everything when I hit
> >> tab in a place without context" which is exactly what it should do.
> >> If not, I suggest turning off tab completion first and trying again.
> >
> > yes,,...>>>>How do you turn off tab completion in IRB?
> ...how do turn off the tab because that was the case (sort of speak)
> i mean i use sciteK editor the comes with the one-click installer and i
> guess i puts a tab in there somewhere but i don't know how?
>
> --
> Posted via http://www.ruby-....
>
>

Ken Bloom

9/18/2006 4:13:00 AM

0

On Sat, 16 Sep 2006 12:02:18 +0900, x1 wrote:

> On 9/15/06, Dave Rose <bitdoger2@yahoo.com> wrote:
>> Ken Bloom wrote:
>> > On Sat, 16 Sep 2006 04:58:12 +0900, Ryan Davis wrote:
>> >
>> >>>>> while r=cursor.fetch() and k.size<3
>> >>>>> end
>> >>
>> >> I can't even tell what you are trying to do / write. It looks like
>> >> "freak out" in your world means "respond with everything when I hit
>> >> tab in a place without context" which is exactly what it should do.
>> >> If not, I suggest turning off tab completion first and trying again.
>> >
>> > yes,,...>>>>How do you turn off tab completion in IRB?
>> ...how do turn off the tab because that was the case (sort of speak)
>> i mean i use sciteK editor the comes with the one-click installer and i
>> guess i puts a tab in there somewhere but i don't know how
>
> in scite, just hit F5 to execute the app/script.. no need to past to
> irb (assuming that's what you're doing

I prefer my gvim and my xterm, thank you very much. How do I turn off tab
completion in IRB?

--Ken

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...

Reprisal

9/18/2006 4:54:00 AM

0

> I prefer my gvim and my xterm, thank you very much. How do I turn
> off tab
> completion in IRB?

irb -f --readline #ignore .irbrc file and load readline w/o tab
completion
irb --noreadline #disable readline altogether



Ken Bloom

9/18/2006 1:29:00 PM

0

On Mon, 18 Sep 2006 13:53:44 +0900, Reprisal wrote:

>> I prefer my gvim and my xterm, thank you very much. How do I turn
>> off tab
>> completion in IRB?
>
> irb -f --readline #ignore .irbrc file and load readline w/o tab
> completion
> irb --noreadline #disable readline altogether

It seems that I don't have a .irbrc, but I still have tab completion. I'd
like to have readline support but no completion, but I don't know what to
put in my .irbrc (or .inputrc) to disable this.

--Ken

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...

Ken Bloom

9/18/2006 8:16:00 PM

0

Ken Bloom <kbloom@gmail.com> wrote:
> On Mon, 18 Sep 2006 13:53:44 +0900, Reprisal wrote:
>
>>> I prefer my gvim and my xterm, thank you very much. How do I turn
>>> off tab
>>> completion in IRB?
>>
>> irb -f --readline #ignore .irbrc file and load readline w/o tab
>> completion
>> irb --noreadline #disable readline altogether
>
> It seems that I don't have a .irbrc, but I still have tab completion. I'd
> like to have readline support but no completion, but I don't know what to
> put in my .irbrc (or .inputrc) to disable this.

I figured it out. Somehow, at the end of
/usr/lib/ruby/1.8/irb/completion.rb, I have the lines:

if Readline.respond_to?("basic_word_break_characters=")
Readline.basic_word_break_characters= " \t\n\"\\'`><=;|&{("
end
Readline.completion_append_character = nil
Readline.completion_proc = IRB::InputCompletor::CompletionProc

So I just put code in my .irbrc to undo it:
#disable completion, so that hitting tab just inserts a tab character
Readline.completion_append_character = ""
Readline.completion_proc = lambda {|x| x+"\t"}

--Ken Bloom

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...

slika

9/1/2010 9:38:00 AM

0


"Scout" <me4guns@verizon.removeme.this2.nospam.net> wrote in message
news:i5kgl9$rpn$1@news.eternal-september.org...
> Speeders & Drunk Drivers are MURDERERS wrote:
>> If so, let's see it. The govt just says THREE WTC skyscrapers
>> collapsed straight down
>
> Speedy is now claiming to be the government.......

Debunkers have been claiming that for themselves for years now...


BDK

9/1/2010 7:10:00 PM

0

In article <4c7e2428@news.x-privat.org>, slika@hotmail.com says...
>
> "Scout" <me4guns@verizon.removeme.this2.nospam.net> wrote in message
> news:i5kgl9$rpn$1@news.eternal-september.org...
> > Speeders & Drunk Drivers are MURDERERS wrote:
> >> If so, let's see it. The govt just says THREE WTC skyscrapers
> >> collapsed straight down
> >
> > Speedy is now claiming to be the government.......
>
> Debunkers have been claiming that for themselves for years now...
>
>
>

Another lie from the sneering assclown.
--
BDK, non-jew leader of the non-existant paid jew shills!