16
GLBasic - en / Re: Compiler Interperets All Variables as Incorrectly Defined
« on: 2013-Apr-01 »
Static is not important to learn in the start though.
Quick info is that STATIC is similar to LOCAL except the information stays in the variable until the program shuts down.
This means that a function can have variables that retains the information for each call. For example a counter of how many times the function has been called so a recursive function knows when to stop calling itself.
Another use could be a function that paints an object on screen. The function could be called with
Quick info is that STATIC is similar to LOCAL except the information stays in the variable until the program shuts down.
This means that a function can have variables that retains the information for each call. For example a counter of how many times the function has been called so a recursive function knows when to stop calling itself.
Another use could be a function that paints an object on screen. The function could be called with
Code: [Select]
draw_turtle("init", x, y) first time and save the location x and y as static variables. The second time you call the function it would be enough withCode: [Select]
draw_turtle("forward")
draw_turtle("turn_left")because it remembers the location from the last call. (turtle grafics from really old-school basic :-)
