Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Default text entered in a puts dialog

Reply
Thread Tools

Default text entered in a puts dialog

 
 
12 34
Guest
Posts: n/a
 
      06-20-2007
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

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Jano Svitok
Guest
Posts: n/a
 
      06-20-2007
On 6/20/07, 12 34 <> wrote:
> 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

 
Reply With Quote
 
 
 
 
12 34
Guest
Posts: n/a
 
      06-20-2007
Jano Svitok wrote:
> On 6/20/07, 12 34 <> wrote:
>> 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.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Morton Goldberg
Guest
Posts: n/a
 
      06-20-2007
On Jun 20, 2007, at 2:32 PM, 12 34 wrote:

> Jano Svitok wrote:
>> On 6/20/07, 12 34 <> wrote:
>>> 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



 
Reply With Quote
 
12 34
Guest
Posts: n/a
 
      06-21-2007
Morton Goldberg wrote:
> On Jun 20, 2007, at 2:32 PM, 12 34 wrote:
>
>>>

>> field. Works OK if the field is filled in.

> 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.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add new text box after entered text cmgmyr Javascript 1 05-27-2008 04:44 PM
what's the diff between puts y and puts "#{y}" in class_eval Raj Singh Ruby 4 01-29-2008 10:16 PM
Suggestion: swap name of "puts" and "print" and rename "puts" to"put_s" Michael Brooks Ruby 22 03-27-2007 04:57 PM
Compare Validator - fires before text entered is completed =?Utf-8?B?U2FuZHk=?= ASP .Net 3 02-12-2005 11:58 AM
Date entered from textbox becomes null (1/1/1900) when entered into SQL table. TN Bella ASP .Net 1 07-01-2004 02:53 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57