Forum: Ruby Ruby shoes file writing problems

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
87884b914bb442d23bff13677ca7b63c?d=identicon&s=25 Daniel Meskin (danielm)
on 2017-03-23 02:01
Attachment: diaryshoes.rb (910 Bytes)
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.
This topic is locked and can not be replied to.