# Case statement not being picked up

**URL:** <https://www.ruby-forum.com/t/case-statement-not-being-picked-up/64858>\
**Category:** Ruby\
**Created:** [August 15, 2006, 2:19pm UTC](https://www.ruby-forum.com/t/case-statement-not-being-picked-up/64858 "2006-08-15T14:19:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [August 15, 2006, 2:19pm UTC](https://www.ruby-forum.com/t/case-statement-not-being-picked-up/64858/1 "2006-08-15T14:19:54Z")

</div>

Hi,

This is my code and I have printed out some de-bug statements. I  
haven’t a clue why the task = ‘validate’ switch statement is not being  
executed.

`
class Form
def initialize
#see if file exists, what file or we going to use?
#@filename = “search.txt”
@filename = “validate.txt”
end
def enter_data
task = nil
count = 1
flag = 0
```
read_in_test_data.each { |x|
line = x.chomp
 #debug
 p "line = #{x.chomp}"
case line
  when /^\*+ TESTID_\d+$/
    p line.gsub(/\*/, '')
    flag += 1
    if flag > 1
      $ie.back
      count = 1
    end
  when /^Address:$/
    task = :address
  when /^Country:$/
    task = :country
  when /^Search-Results:$/
    task = :search
  when /^Validate:$/
    task = :validate
  when /^Expected-Result:$/
    task = :verify
  when /^END:$/
    $ie.close
else
  p "the task = #{task}"
  case task
    when :address
      $ie.text_field(:name, "AL#{count}").set(line)
      count += 1
    when :country
      $ie.text_field(:name, 'C1').set(line)
    when :validate
      $ie.button(:value, 'Validate').click
    when :search
      $ie.text_field(:name, 'NR1').set(line)
      $ie.button(:value, 'Search').click
    when :verify
      if $ie.contains_text(line)
        p line, "PASS"
      else
        p line, "FAIL"
      end
  else
      #whatever
  end
end
}

```
end
def read_in_test_data
#check if file exists and give date of last change
File.readlines(@filename, “\n” )
end
private:read_in_test_data
end

debug statements
“line = *********************************************** TESTID_100”
" TESTID_100"
“line = Address:”
“line = Choyce Close”
“the task = address”
“line = Country:”
“line = GB”
“the task = country”
“line = Validate:”
“line = Expected-Result:”
"line = Is Complete: "
“the task = verify”
the file being read
*********************************************** TESTID_100
Address:
Choyce Close
Country:
GB
Validate:
Expected-Result:
Is Complete:
false
Confidence Level:
0
Address:
Postal Authority Formatted Address:
Choyce Close
United Kingdom
*********************************************** TESTID_200
etc
Much appreciated
Aidy`

---

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [August 15, 2006, 2:19pm UTC](https://www.ruby-forum.com/t/case-statement-not-being-picked-up/64858/2 "2006-08-15T14:19:55Z")

</div>

I am still struggling without a visual debugger within an IDE, even  
though I have ordered a license of Arachno Ruby it may take a couple of  
days for that license to be sent.

The Arachno developers have promised that the debugger will work with  
Ruby 184x

Cheers

Aidy

---

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [August 15, 2006, 2:19pm UTC](https://www.ruby-forum.com/t/case-statement-not-being-picked-up/64858/3 "2006-08-15T14:19:56Z")

</div>

aidy wrote:

> Hi,
> 
> This is my code and I have printed out some de-bug statements. I  
> haven’t a clue why the task = ‘validate’ switch statement is not being  
> executed.
> 
> `
> `

[…]

Check your indentation. You read a line. If you recognize it, you set  
the task. If you don’t recognize it, you print “the task = …” and do  
something related to the task.

Since “Expected-Result” is recognized, you never get to process the  
validate action. You need to intercalate a blank line or something (or  
change your algorithm).
