Variable not Found (Update_Var_Array)

On the attached program, when it reaches line 205 (almost the end), I get the following message and execution stops.
Variable not Found (Update_Var_Array)
Code:
#picaxe 28x1
'#com 4
 
'Variables
Symbol RXIN =W0
Symbol DLYin=W2
Symbol Dly = b6
Symbol M=b4
Symbol N=b5
Symbol R=b7
Symbol Dty=W10

Pause 5000
'Pins

Symbol RX_IN= Input0

 	let dirsc = %11110010
 	let pinsc = %00000000
 		`SetInt %00000100,%00000100
Main:

	Dly=30
	Pulsin 0,1,RXIN
	if RXIN>150 then goto Show
	Goto landing

			Show:
	For R=0 to 5
	Pulsin 0,1,RXIN
	if RXIN>150 then goto Forw
	High PortC 2
		Forw:
	Pulsin 0,1,RXIN
	if RXIN>150 then goto Forw1
	Goto landing
	Forw1:
	let pinsc=%00000010
	pause Dly
	let pins=%00000000
	M=%10000000
	
	for N=0 to 7
	let pins=M
	M=M/2
	pause Dly
	Next N
	let pinsc=%00000000
	let pins=%00000000
	pause DLY
	let pinsc=%10000000
	Pause Dly
	let pinsc=%01000000
	Pause Dly
	let pinsc=%00100010
	Pause Dly
	let pinsc=%00000000
	pause Dly
	let pinsc=%00000010
	
	
	Next R
	Pause 20
	DLY=DLY+5
	
	For R=0 to 5
	
		Forback:
		Pulsin 0,1,RXIN
	if RXIN>150 then goto Forback1
	Goto landing
	Forback1:
	'let dirsc=%11110010
	
	pause Dly
	let pins=%00000000
	M=%10000000
	let pinsc=%00000010
	for N=0 to 7
	let pins=M
	M=M/2
	pause Dly
	Next N
	let pins=%00000000
	let pinsc=%10000000
	Pause Dly
	let pinsc=%01000000
	Pause Dly
	let pinsc=%00100010
	Pause Dly
	let pinsc=%00000000
	Pause Dly
	Pause Dly
	let pinsc=%00100010
	pause Dly
	let pinsc=%01000000
	pause Dly
	pause Dly
	let pinsc=%10000010
	pause Dly
	let pinsc=%00000000
	pause Dly
	M=%00000001
	For N=0 to 7
	let pins=M
	M=M*2
	pause Dly
	Next N
	let pinsc=%00000010
	
	Next R
	Pause 20
	

	Dly=51
	For R=0 to 10

		Fromcent:
	Pulsin 0,1,RXIN
	if RXIN>150 then goto Fromcent1
	Goto landing
	Fromcent1:
	Let pinsc=%00000010
	Pause Dly
	let pinsc=%00000000
	
	let pins=%00000100
	Pause Dly
	let pins=%00000010
	Pause Dly
	let pins=%00000001
	Pause Dly
	let pins=%00100000
	let pinsc=%10000000
	Pause Dly
	let pins= %01000000
	let pinsc=%01000010
	Pause Dly
	let pins=%10000000
	let pinsc=%00100000
	pause Dly
	let pinsc=%00000000
	let pins=%00000000
	Pause Dly
	let pins= %10000000
	let pinsc=%00100000
	Pause Dly
	let pins= %01000000
	let pinsc=%01000010
	Pause Dly
	let pins=%00100000
	let pinsc=%10000010
	Pause Dly
	let pins=%00010001
	let pinsc=%00000000
	Pause Dly
	let pins=%00001010
	Pause Dly
	let pins=%00000100
	'Dly=Dly-5 min 15
	Pause Dly
	let pinsc=%00000010
	Dly=Dly-1
	Next R
	Dly=30
	Pause 20
	Goto Main
	
	For R=0 to 5
		LANDING:
	
	let pinsc=%00010010
	pause Dly
	let pins=%00000000
	M=%10000000
	
	for N=0 to 7
	let pins=M
	M=M/2
	pause Dly
	Next N
	let pinsc=%00010000
	let pins=%00000000
	pause DLY
	let pinsc=%10010000
	Pause Dly
	let pinsc=%01010000
	Pause Dly
	let pinsc=%00110010
	Pause Dly
	let pinsc=%00010000
	pause Dly
	let pinsc=%00010010
	Next R [B][COLOR="Red"]'THIS IS LINE 205[/COLOR][/B]
	
	Pause 20
	Pulsin 0,1,RXIN
	if RXIN>150 then goto Main
	Goto Landing
 

BeanieBots

Moderator
I've just cut'n'paste your code into PE 5.2.4 and it syntax checked OK for me.

What version are you using?

EDIT:
I get the same error if I try to simulate it.
Does it work if you download to a chip?
 
Last edited:

boriz

Senior Member
With just a quick glance...

The LANDING label is after the FOR R line, so the GOTO LANDING line might be bypassing some of the internal Picaxe FOR...NEXT processing. You are jumping into a FOR...NEXT loop.

You won’t get an error when you compile it, but during execution, if the program ever gets to NEXT R before it has processed a FOR R, then there could be some sort of trouble.
 

hippy

Ex-Staff (retired)
Your code is confusing to follow, "Goto Landing" with "Landing:" inside a FOR-NEXT loop, and it appears that this is also confusing the simulator, eq ...

Goto Landing
For b0 =1 to 10
Landing:
Next

We will investigate this issue but if you can rewrite the program without jumping into the FOR-NEXT that may perform better when simulating.
 
Beanie, I am running 5.2.4
Hippy and Boriz, you guys are right, I changed the code and it works fine now
THANK YOU ALL​

Code:
	LANDING:
	For RR=0 to 5
	let pinsc=%00010010
	pause Dly
	let pins=%00000000
	M=%10000000
	for N=0 to 7
	let pins=M
	M=M/2
	pause Dly
	Next N
	let pinsc=%00010000
	let pins=%00000000
	pause DLY
	let pinsc=%10010000
	Pause Dly
	let pinsc=%01010000
	Pause Dly
	let pinsc=%00110010
	Pause Dly
	let pinsc=%00010000
	pause Dly
	let pinsc=%00010010
	Next RR 
	Pause 20
	Pulsin 0,1,RXIN
	if RXIN>150 then goto Main
	Goto Landing
 
Top