I am writing a program that will write a diary for the user, however i'm having a bit of trouble... Here's my code:
Shoes.app :title => "Diario", :width => 640, :height => 430 do
name = ask("Name")
n1 = ask("Yesterday's Date")
n2 = ask("Today's Date")
n3 = ask("Tommorow's Date")
w1 = ask("Yesterday's weather")
w2 = ask("Today's Weather")
w3 = ask("Tommorow's Weather")
a1 = ask("Yesterday's Activity")
a2 = ask("Today's Activity")
a3 = ask("Tommorow's Activity")
m = ask("Mood")
tw = ask("Today was...")
sn = ask("Special Notes")
@entry
para "Dear diary, The date is " + n2 + ". It is " + w2 + ". I will go to " + a2 + "."
para "Yesterday was " + n1 + ". It is " + w1 + ". I will go to " + a1 + "."
para "Tomorrow is " + n3 + ". It is " + w3 + ". I will go to " + a3 + "."
para "Today was " + tw + ". " + sn + "I am feeling " + m + "."
end
button "Save", :width => 85 do
file = ask_save_file
File.open(file, "w+") do |f|
@file.text = File.write(@entry.text)
end
end
- But when I run the code I get this-
Error in <unknown> line 0 | 2017-03-15 20:44:14 -0400
undefined method `button' for main:Object
I know this is an ametuer mistake, but please help me anyway? Thanks, Daniel M.
UPDATE: Problem solved; I just had to move the first 'END' to the end - it was closing the app block. However, When I save to a file now, it saves as a blank file... any ideas?
button is outside Shoes.app block
require 'shoes'
Shoes.app :title => "Diario", :width => 640, :height => 430 do
name = ask("Name")
n1 = ask("Yesterday's Date")
n2 = ask("Today's Date")
n3 = ask("Tommorow's Date")
w1 = ask("Yesterday's weather")
w2 = ask("Today's Weather")
w3 = ask("Tommorow's Weather")
a1 = ask("Yesterday's Activity")
a2 = ask("Today's Activity")
a3 = ask("Tommorow's Activity")
m = ask("Mood")
tw = ask("Today was...")
sn = ask("Special Notes")
@entry
para "Dear diary, The date is " + n2 + ". It is " + w2 + ". I will go to " + a2 + "."
para "Yesterday was " + n1 + ". It is " + w1 + ". I will go to " + a1 + "."
para "Tomorrow is " + n3 + ". It is " + w3 + ". I will go to " + a3 + "."
para "Today was " + tw + ". " + sn + "I am feeling " + m + "."
button "Save", :width => 85 do
file = ask_save_file
File.open(file, "w+") do |f|
@file.text = File.write(@entry.text)
end
end
end