Irb freaks out over a case stmt

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-forum.com/\.

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 Ruby | zenspider.com | by ryan davis for examples of how to write properly formed case statements.

···

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)

How do you turn off tab completion in IRB?

···

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.

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

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-forum.com/\.

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-forum.com/\.

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

--Ken

···

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

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

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

···

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

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

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

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