MicroWorlds


Buttons for Day and Night

Buttons can make things happen. We will create two buttons to allow us to switch from day to night and back again.

1 Pick the button tool from the Tool Palette shape

2 Click on the page where you want the button to appear. A dialog box will appear. Type Day in the box.

3
Click OK

4
A button with Day on it will appear

5
Create another button, this time night will be the instruction.

Clicking on one of these buttons will result in an error message:
"I don't know how to day"

Day is not a command that MicroWorlds understands. This word will be added to its vocabulary. Day will change the sky colour to blue and night will change the colour to black. First though, type this in the Command Center.

setbg "sky
setbg "black

Setbg stands for set background.
Remember the quotation mark before colour name.

Now we will tell MicroWorlds that this is what we mean by day and night.


Choose procedures from the pages menu. The procedures page is the place where the procedures (programs) are written. A procedure is a list of instructions to which a name is given. Once a procedure is defined, typing its name is like typing all the instructions it contains.

Type this on the Procedures page.
 to day
  setbg "sky
 end


to night
 setbg "black
end

Now return to your page (Page 1).

Select your page name from the pages menu.

Now try the two buttons.

If the buttons don't work, you may have used the paint can to colour in the sky. Setbg can't colour over it. Use the eraser in the Drawing Center to erase the coloured sky and then try the buttons again.

Save you project in preparation for Typing Text.





Last Update: 22-Jun-2007