Default text entered in a puts dialog

1

12 34

I want to put a default answer in the text entry box that appears when
you puts some text.

photoGMT = -4
puts "What time zone are the photos in?"
answer = gets.chomp.to_i

I'd like photoGMT to appear as a default answer. I know this wouldn't be
very convenient in Terminal, but works well with TextMate.

For ASers this is equivalent to

set photoGMT to -4
display dialog "What time zone are the photos in?" default answer
photoGMT
 
J

Jano Svitok

I want to put a default answer in the text entry box that appears when
you puts some text.

photoGMT = -4
puts "What time zone are the photos in?"
answer = gets.chomp.to_i

I'd like photoGMT to appear as a default answer. I know this wouldn't be
very convenient in Terminal, but works well with TextMate.

For ASers this is equivalent to

set photoGMT to -4
display dialog "What time zone are the photos in?" default answer
photoGMT

This is the best I can imagine: you cannot fill the input buffer
easily, so I propose to use the default value if the reply is empty.

photoGMT = -4
puts "What time zone are the photos in? [#{photoGMT}]"
ans = gets.strip
answer = ans.empty? ? photoGMT : ans.to_i


Jano
 
1

12 34

Jano said:
For ASers this is equivalent to

set photoGMT to -4
display dialog "What time zone are the photos in?" default answer
photoGMT

This is the best I can imagine: you cannot fill the input buffer
easily, so I propose to use the default value if the reply is empty.

photoGMT = -4
puts "What time zone are the photos in? [#{photoGMT}]"
ans = gets.strip
answer = ans.empty? ? photoGMT : ans.to_i


Jano

TextMate errors on strip. I change to chomp and TextMate errors on empty
field. Works OK if the field is filled in.

Thanks for trying.
 
M

Morton Goldberg

Jano said:
For ASers this is equivalent to

set photoGMT to -4
display dialog "What time zone are the photos in?" default answer
photoGMT

This is the best I can imagine: you cannot fill the input buffer
easily, so I propose to use the default value if the reply is empty.

photoGMT =3D -4
puts "What time zone are the photos in? [#{photoGMT}]"
ans =3D gets.strip
answer =3D ans.empty? ? photoGMT : ans.to_i


Jano

TextMate errors on strip. I change to chomp and TextMate errors on =20
empty
field. Works OK if the field is filled in.

I ran the above code in TextMate with Run (cmd-R) and it worked fine. =20=

It only failed when I tried to execute it with Execute and Update =91# =20=

=3D>=92 Markers (ctl-shift-cmd-E). Did you execute with Run or with =20
Execute ...?

Regards, Morton
 
1

12 34

Morton said:
I ran the above code in TextMate with Run (cmd-R) and it worked fine.
It only failed when I tried to execute it with Execute and Update �#
=>� Markers (ctl-shift-cmd-E). Did you execute with Run or with
Execute ...?

Regards, Morton

An update fixed the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top