Local Variables (New Features)

by Jim ⌂ @, Russell, KY, Tuesday, October 30, 2012, 22:31 (1698 days ago) @ M Santos

Variables are being stored based on the call stack depth and are static between calls. This behavior can get crazy at times and we need to look at it, it was the easiest way to implement local variables.

The following code does not use the static nature that you were having problems with.

Let me think about this.


graphsize 900,500
fastgraphics

ritax=400
sidneyx = 400

for p = 1 to 100000 step 1
call ritacar(ritax,60)
call sidneycar(sidneyx,60)
ritax = ritax + 1
if ritax>1000 then ritax = 0
sidneyx = sidneyx + 1.5
if sidneyx>1200 then sidneyx = 0
refresh
clg
next p


subroutine ritacar(x,y)
color yellow
rect 910-x,270+y,60,20
color yellow
rect 930-x,230+y,70,60
color black
font "Arial Black",12,50
Text 935-x,230+y,"School"
color darkcyan
rect 935-x,250+y,60,20
color black
circle 925-x,290+y,10
color black
circle 990-x,290+y,10
end subroutine

subroutine sidneycar(x,y)
color darkblue
rect 910-x,270+y,60,20
color darkblue
rect 930-x,260+y,40,20
color black
circle 925-x,290+y,10
color black
circle 955-x,290+y,10
end subroutine


Complete thread:

 RSS Feed of thread

powered by my little forum