03 — Set: store a value
A value is a box with a name. set puts something in the box, and show
takes it out later.
Steps
Create
store.nme:
run it →set greeting to Hello show greetingThis prints
Hello. The namegreetingnow stands for that text.Numbers work the same way:
run it →set answer to 7 set answer to 10 show answeransweris a box: putting10in replaces7, so the program prints10.Korean puts the name first:
run it →인사는 안녕하세요 정답은 7인사는 ...and정답은 ...store text and numbers exactly like the English forms.The action word can come after the name too:
run it →name save Mina 이름 저장 민수Several values at once go in a list, separated by commas:
run it →set friends to list of Mina, Ada append Grace to friends show friendsWriting nothing after
list ofgives an empty list, which is how you start when the values arrive later:
run it →set jobs to list of append sweeping to jobs show jobsThe Korean forms are
친구들은 목록 민수, 지안and친구들에 서준 넣어.
Try it yourself
Store your age as a number and a favorite place as text, then show both:
set age to 12
set place to Seoul
show place
run it →What you learned
set name to valuestores a value;이름은 값is the Korean form.- Putting a new value in a name replaces the old one.
- Text and numbers are both stored without quotes.
name save value/이름 저장 값are accepted word orders.set friends to list of Mina, Adakeeps several values under one name, andappend Grace to friendsadds one more.