| 1 |
// Listing 5.4 Local vs. global scope of variables |
| 2 |
|
| 3 |
// Define some global variables |
| 4 |
"HOWDY!!" => string howdy; |
| 5 |
100.0 => float glob; |
| 6 |
int int1, int2; |
| 7 |
|
| 8 |
// Function definition |
| 9 |
fun int interval( int note1, int note2) |
| 10 |
{ |
| 11 |
int result; |
| 12 |
note2 - note1 => result; |
| 13 |
<<< howdy, glob >>>; |
| 14 |
return result; |
| 15 |
} |
| 16 |
|
| 17 |
// Main program, test and print |
| 18 |
interval(60,72) => int1; |
| 19 |
interval(67,60) => int2; |
| 20 |
|
| 21 |
<<< int1, int2 >>>; |
| 22 |
|
| 23 |
<<< result >>>; // This line will cause an error |
| 24 |
// comment it out to run program up to this point |
| 25 |
|