Variables


Text of video

A variable is only available in the procedure where it is delared, that is it is local to that procedure.
A global variable is one that is not declared inside a procedure or function.
A global variable can be accessed, changed, or modified anywhere in the program.
Variables that are declared inside a procedure or function are local: they can only be used inside the procedure or function where they are declared.

We are going to create a counter program by making counter global.
The counter will be declared outside of the procedures, making it global. Write the code as shown in the video.

Experiment: Add a button to reset the counter to 0. Add a button to subtract 1.

NEXT: Arithmetic Operations