Hello,
First let me thank everyone who is responding. This is excellent. I have
reviewed a great deal of the feedback and appreciate it. After reviewing the
example code snippets I came up with the following. I think it represents a
better overall script.
Your thoughts are appreciated:
#!/usr/bin/env ruby
File.open('phonespec.txt', 'a') do |aBook|
puts <<EOT
Welcome to MyAddressbook. Please follow the prompts.
If you wish to end data entry, you may do so at any time.
Just type the word END into a prompt.
EOT
addrData = Array.new
addrFields = ["First Name", "Last Name", "Phone Number"]
x = 0
loop do
print "\n\t#{addrFields[x]}: "
getLine = gets
break if getLine == "END\n"
addrData[x] = getLine.chop!
x += 1
if x == addrFields.length
aBook.puts addrData.join("\t")
addrData.clear
x = 0
end
end
puts "\n\nTo start the program again please type addr.rb\n\tGoodBye!\n"
end