[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Help with user input

Vincent Foley

5/25/2005 11:39:00 PM

Hi,

I would like to write a small script in which a user enters a small
pager message. The message can't be longer than 60 characters however,
and instead of informing him after he pressed enter, forcing him to
retype it again or copy and pasting and then editing, is there a way I
could say how many characters are left? Something like:

Enter message (42 chars left): I am the king of the

I would prefer not to use curses if at all possible.

1 Answer

greg7224

5/26/2005 12:40:00 AM

0

>Vincent Foley writes:
>I would like to write a small script in which a user enters a small
>pager message. The message can't be longer than 60 characters however,
>and instead of informing him after he pressed enter, forcing him to
>retype it again or copy and pasting and then editing, is there a way I
>could say how many characters are left? Something like:
>
>Enter message (42 chars left): I am the king of the
>
>I would prefer not to use curses if at all possible.

This is really low tech but it might work. do character based input,
and clear the screen and print the prompt plus the keys already
inputted.

You've looked at the highline source, so take a look at how we do cross
platform character reading, and just adapt it to your needs... I'd just
append the entered chars into a String as the user types them.

If you can make this type of prompt into a nice function, please send
it to me because it seems like it might have a place in HighLine.