For Beginners

Lesson 12/18

Procedures with Parameters

A procedure can be called with a parameter. A parameter is a form of a variable you define with procedure command. For example:

procedure changefont size 10

will define the size parameter for the changefont procedure and set it to a default value of 10.

Now, let's call the changefont procedure and pass the value of the ♥fontsize variable to the procedure's size parameter:

program notepad
keyboard Hello⋘enter⋙world!
for ♥fontsize from 10 to 100 step 10
    call changefont size ♥fontsize
end for

procedure changefont size 10
	keyboard ⋘alt+o⋙f
	window font
	keyboard ⋘tab 2⋙♥size⋘enter⋙
end procedure

Note that the size parameter automatically defines ♥size variable used in the last line of the procedure. In this example the ♥size variable will get its value directly from the ♥fontsize variable — this is done with the call changefont size ♥fontsize command.

Try changing the starting value of the ♥fontsize variable to 30 in the script above:

for ♥fontsize from 30 to 100 step 10

and run it. You will see that the default value of the size parameter (10 in this case) will be overridden with the starting value of the ♥fontsize variable, which equals 30.

The next lesson will explain lists.