Page 1 of 1

Calling Outside Variables Within Functions?

Posted: Mon Sep 14, 2015 9:04 pm
by the_wesley_watkins
Is there anyway to use a variable created outside of a function within a function?


Such as:

Code: Select all

GRAPHICS
GRAPHICS CLEAR 0.34,0.34,0.34

x = 25
y = 25
w = 10
h = 10

DEF drawRect

	FOR COUNT = 1 TO 5
		DRAW RECT x * COUNT, y SIZE w, h
	NEXT COUNT

END DEF


CALL drawRect

Re: Calling Outside Variables Within Functions?

Posted: Mon Sep 14, 2015 9:43 pm
by Mr. Kibernetik
Yes, of course.

Use null scope name when using global (defined in main program body) variables:

Code: Select all

GRAPHICS
GRAPHICS CLEAR 0.34,0.34,0.34

x = 25
y = 25
w = 10
h = 10

DEF drawRect

   FOR COUNT = 1 TO 5
      DRAW RECT .x * COUNT, .y SIZE .w, .h
   NEXT COUNT

END DEF


CALL drawRect