Shop OBEX P1 Docs P2 Docs Learn Events
Spin2 REPEAT issue — Parallax Forums

Spin2 REPEAT issue

Hi Chip
I've found an issue with the REPEAT command in Spin2.
If I use a variable directly with a repeat I get incorrect count.
If I use the same variable in the from/to format it works Ok.
var
	parm[8]

pub main()|x

	waitms(2500)			'wait leds to extingish after load
	parm[1] := 7

'	repeat parm[1]			'flashes 4 times ???
	repeat x from 1 to parm[1]	'fkashes 7 times as expected
		pinl(56)
		waitms(500)
		pinh(56)
		waitms(500)

Comments

  • Another test shows locals work Ok
    '
    var
    	parm[8]
    
    pub main()|x,y
    
    	waitms(2500)			'wait leds to extingish after load
    	parm[1] := 7
    	y := 7
    
    	repeat y			'local works Ok too!
    '	repeat parm[1]			'flashes 4 times ???
    '	repeat x from 1 to parm[1]	'fkashes 7 times as expected
    		pinl(56)
    		waitms(500)
    		pinh(56)
    		waitms(500)
    
    
  • cgraceycgracey Posts: 14,133
    edited 2020-04-02 12:07
    Ozpropdev, thanks for alerting me to this. A constant flag in the compiler was being set by the constant index, but because it was a variable to begin with, I just needed to clear the constant flag after getting the constant index, so that the REPEAT compiler didn't think the constant index was all there was. There's a new PNut_v34Q. Q fixes the problem.
Sign In or Register to comment.