A variable can be thought of as a for different values. You can change the value of a ‘container’ variable at any time. make 20 MSW Logo uses a statement in the form: “MyVariable to assign a value to a variable. label :MyVariable The value of the variable is accessed in the form: (NOTE: the colon in front of the variable name.) Eg to multiply make 16 “Number1 make 3 “Number2 make :Number1 * :Number2 “Answer label :Answer end IMPORTANT You need to understand the difference between a variable and ordinary – text. When accessing a variable’s value you must put a colon in front of the variable name. Eg. hello LABEL hello will produce – Whereas Make 79 “hello 79 :hello will produce – an error will produce LABEL hello * 2 Whereas 158 will produce LABEL :hello * 2 Passing Values into Procedures Eg to box :size Repeat 4 [fd :size rt 90] end The size of the box can be determined by the value typed in when running the procedure. Eg box 20, box 40 , etc. NOTE: If you type in without the MSW Logo will report box, an error. User Input
A variable can be thought of as a ‘container’ for different values. You can change the value of a variable at any time. MSW Logo uses a statement in the form: make “MyVariable 20 to assign a value to a variable. The value of the variable is accessed in the form: label :MyVariable (NOTE: the colon in front of the variable name.) Eg to multiply make “Number1 16 make “Number2 3 make “Answer :Number1 * :Number2 label :Answer end IMPORTANT – You need to understand the difference between a variable and ordinary text. When accessing a variable’s value you must put a colon in front of the variable name. Eg. LABEL hello will produce – hello Whereas Make “hello 79 :hello will produce – 79 LABEL hello * 2 will produce an error Whereas LABEL :hello * 2 will produce 158 Passing Values into Procedures Eg to box :size Repeat 4 [fd :size rt 90] end The size of the box can be determined by the value typed in when running the procedure. Eg box 20, box 40 , etc. NOTE: If you type in box, without the MSW Logo will report an error. User Input