I am writing a diary app in ruby shoes that writes a diary from a user
provided template. Here is 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”)
@box = edit_box :width => 1.0, :height => 400, :text =>"Dear diary, The
date is " + n2 + ". It is " + w2 + ". I will go to " + a2 + “.” +
"Yesterday was " + n1 + ". It is " + w1 + ". I will go to " + a1 +
“.”+"Tomorrow is " + n3 + ". It is " + w3 + ". I will go to " + a3 +
“.”+"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 = f.write(@box)
end
end
end
The save button works fine, however, I just get a text file that looks
like this:
(Shoes::Types::EditBox)
_
Also, I want the program to automatically set the save as file type to
.txt, so the user doesn’t have to append it manually.
__
Any suggestions?
Thanks, Daniel M.