Help with user input

V

Vincent Foley

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

Greg Brown

Vincent said:
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.
 

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

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,477
Latest member
ColumbusMa

Latest Threads

Top