News : The level of daily SPAM has reached insane proportions, all registrations are now admin activated. I also ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to activate your account and that you are not a bot or a spammer.


Post Reply  Post Thread 
User Prompt
Author Message
asafp
Member
***


Posts: 81
Group: Registered
Joined: Jan 2008
Status: Offline
Reputation: 0
Post: #1
User Prompt

Does anyone know how to prompt a user for input from a console application? Ideally, it would be able to mask the input for a password type field.

02-27-2008 08:04 AM
Visit this user's website Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 521
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #2
RE: User Prompt

try io.read()

As a simple example, open up lua interactively.
type "var=io.read()"; it will wait for input.
type something else.
type "print(var)"; it will print whatever you typed previously.

I'm not sure about masking, but I'd be surprised if it's not available.

This post was last modified: 02-27-2008 08:35 AM by mikshaw.

02-27-2008 08:34 AM
Find all posts by this user Quote this message in a reply
iGame3D
Moderator
***


Posts: 231
Group: Moderators
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #3
RE: User Prompt

That is so basic. You think this would be step 2 after hello world.

Code:
--[[ lua command line user user input

o = the print() function
p = a prompt to the user
r = response from the computer
i =  i returns input waiting until line feed to continue execution
This example is all one line of code.
--]]

o ,p ,r = print, "Enter your name.","Hello "; o(p); i=io.read(); if i then o(r..i) end;


I had no  idea how to interactively give values to programs running in the command line until now. I'm sure its been in our telnet chat script forever and I totally overlooked it.

Thanks!

This post was last modified: 02-29-2008 09:02 AM by iGame3D.

02-29-2008 08:34 AM
Visit this user's website Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 521
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #4
RE: User Prompt

There is an interesting example of a text-based menu at lua-users:
http://lua-users.org/wiki/SampleCode (AsciiMenu)

03-01-2008 06:59 AM
Find all posts by this user Quote this message in a reply
asafp
Member
***


Posts: 81
Group: Registered
Joined: Jan 2008
Status: Offline
Reputation: 0
Post: #5
RE: User Prompt

Good examples. Thanx.

03-05-2008 03:34 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: