02 — Ask: have a conversation
A program that listens. ask reads what the user types and stores it in a
name.
Steps
Create
greet.nme:
run it →ask name What is your name? show Hello name!Run it and type a name when the program waits:
nme run greetNME inserts the stored answer into the second sentence, so typing
MinaprintsHello Mina!.The same conversation works in Korean:
run it →이름을 물어봐 이름이 뭐예요? 안녕하세요 이름! 말해줘For the gentlest first input, an ordinary question is enough — NME infers the name from the question:
run it →What is your name? Hello name!
Try it yourself
Ask for a city and show it in a sentence:
ask city Which city do you live in?
show I love city!
run it →What you learned
ask name questionstores the typed answer asname;물어봐is the Korean action.- A known name is inserted into a later sentence automatically.
- An ordinary question like
What is your name?also creates the name. show Hello name!printsHelloplus the stored value.