Internal Error with unused Public Const

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Internal Error with unused Public Const

Post by spamiam »

I have the following program that gives the following errors:

Code: Select all

Stepper.bas:20: Internal Error: attempt to use address of "Delay_Timer" before assignment
Stepper.bas:60: Internal Error: attempt to use address of "Counter" before assignment

The code is as follows

Code: Select all

Option Explicit
Option TargetCPU ZX24ae
Option Base 0



'Public Const LCDOutputPin	as Byte = 5
'Public Const LCDInputPin	as Byte	= 0
'Public Const LCDPort		as Byte	= 3


Public Const StepperA		as Byte	= 28 'PB0
Public Const StepperA_Bar	as Byte	= 27 'PB1
Public Const StepperB		as Byte	= 26 'PB2
Public Const StepperB_Bar	as Byte	= 25 'PB3
Public Const Clear_Pins		as Byte = &b0000_1111

Public Half_Steps(8) as Byte 

Public	Delay_Timer as Integer = 220	'ticks

' FDK Stepper:
' A = Blue
' A_Bar = Yellow
' B = Red
' B_Bar = White




Sub Main()

'initialize variables

Half_Steps(0) = &B1010_0000
Half_Steps(1) = &B1000_0000
Half_Steps(2) = &B1001_0000
Half_Steps(3) = &B0001_0000
Half_Steps(4) = &B0101_0000
Half_Steps(5) = &B0100_0000
Half_Steps(6) = &B0110_0000
Half_Steps(7) = &B0010_0000

' initialize I/O pins
Call PutPin (B.0, zxOutputLow)
Call PutPin (B.1, zxOutputLow)
Call PutPin (B.2, zxOutputLow)
Call PutPin (B.3, zxOutputLow)


'test loop
do
	call PutPin(28, zxOutPutHigh)
	Call Sleep(255)
	Call PutPin(28, zxOutPutLow)
	Call Sleep(255)
loop


Dim Counter as Byte = 0

Do
	'Clear the pins
	Register.PortB = Register.PortB AND Clear_Pins
	
	'Set the pins to the new state
	Register.PortB = Register.PortB OR Half_Steps(Counter)
	
	'increment the state
	Counter = Counter +1
	if (Counter = 8) then 
		counter = 0
	end if
	
	'delay for a moment
	Call Sleep(Delay_Timer)
	Delay_Timer = Delay_Timer -10
	if &#40;Delay_Timer <=20&#41; then
		Delay_timer = 220
	End If
	
Loop

End Sub

I would have thought I would get a warning about an unused variable, but not an internal error.

-Tony
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Internal Error with unused Public Const

Post by dkinzer »

spamiam wrote:I would have thought I would get a warning about an unused variable, but not an internal error.
This problem was discovered since the last "official" release. The recently posted experimental version v2.5.7 of the compiler has the error corrected.
- Don Kinzer
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Re: Internal Error with unused Public Const

Post by spamiam »

dkinzer wrote:This problem was discovered since the last "official" release. The recently posted experimental version v2.5.7 of the compiler has the error corrected.
AH, Sorry for that. I had see that thread, but I did not realize that this problem was the same. I will try the experimental release.

-Tony
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Internal Error with unused Public Const

Post by dkinzer »

spamiam wrote:I had see that thread, but I did not realize that this problem was the same.
Actually, the problem isn't the same as the one for which the experimental version was recommended. It's just that your particular problem had also been fixed.
- Don Kinzer
Post Reply