0:03 look at this little program it looks
0:04 very similar to ones we've already seen
0:07 it creates a variable and then assigns
0:10 it a value over here then there's a
0:13 non-event that allows the variable to
0:15 increase by one every time the button is
0:17 clicked finally we set the property of
0:20 clicks and that just lets us see how
0:22 it's changing over time and we've also
0:25 got this watcher down here so we can see
0:29 how the value of clicks is changing but
0:34 when we run it something weird happens
0:38 over here we're getting na n that stands
0:41 for not a number and down here we're
0:44 seeing that clicks isn't changing at all
0:47 now the solution of fixing this problem
0:49 is pretty easy and for now it's the only
0:56 thing you're going to need to do if you
0:58 switch over in a text mode this is even
1:00 easier you'll see that clicks is being
1:02 created here on line one but we're also
1:09 trying to recreate it on line three we
1:13 go back in the block mode here's the
1:14 program how we're used to seeing it and
1:19 it's not that different but suddenly a
1:22 program runs as we want and we can see
1:24 it both here and down here in the watch
1:30 panel the reason that this is happening
1:34 is because of a concept called scope and
1:36 without getting too into it the basic
1:39 idea is if you create a variable inside
1:42 of a block like on event and in
1:43 particular anything that has this
1:45 function command which you're going to
1:47 learn more about later in this year it
1:51 creates a variable that has local scope
1:54 local scope means that you can only use
1:56 it in the space that it was created and
1:59 that means anywhere inside of this on
2:02 event most variables we want are going
2:05 to have global scope it's best practice
2:07 to create variables for now at the
2:09 beginning of your program like we did
2:13 here on line one while eventually you're
2:14 going to want to create some
2:17 local variables for now we don't and so
2:18 you're going to need to debug programs
2:21 the way we just did make sure you're not
2:24 using a bar inside of a non event use
2:26 your watch panel to see if strange
2:28 things are happening like a variable
2:29 isn't changing when it looks like it
2:32 should and check if you're getting weird
2:34 output for example like we got non it
2:40 not a number later in the course you'll
2:42 learn more how to use this concept but
2:45 for now happy debugging and go catch
2:47 some of those local variables to remove