Repeat/Loop function

TerryRy

Member
The Logicator Repeat dialog has a Repeat X Times option where the number of times to loop can be set to a from 1 to 1000. How can this be possible if variables can only have values between 0 and 256?
 

BillyGreen1973

Senior Member
I dodn't use Logicator, but I would guess it uses a word wariable (eg. W0). Word variables can store 0-65535

However, a way of finding out what Logicator uses, is to write a small loop program and have Logicator export
your prog as a PICAXE BASIC program listing. You will be able to see how it does the repeat/loop.
 

TerryRy

Member
Thanks BillyGreen1973. I'm not very familiar with basic coding and prefer to use the flow diagram approach, accepting its limitations and perhaps inefficient code.

A small program that I have constructed in Logicator using the loop function and a small delay so I can see it work when converted to Basic, defines varA as b0 (single byte 0-255) and sets do loop until varA=1000 which should never be reached. Unfortunately I don't have any hardware to drop the code into at the moment, but running Logicator simulator the simple program operates properly and VarA increments all the way to 1000?

This is the code produced by Logicator -

Code:
symbol varA = b0
symbol varB = b1
symbol varC = b2
symbol varD = b3
symbol varE = b4
symbol varF = b5
symbol varG = b6
symbol varH = b7
symbol varI = b14
symbol varJ = b15
symbol varK = b16
symbol varL = b17
symbol varM = b18
symbol varN = b19
symbol varO = b20
symbol varP = b21
symbol varQ = b22
symbol varR = b23
symbol varS = b24
symbol varT = b25
symbol timer = time

let dirsB = %11111111

main:
		varA = 0		' repeat - reset var
		do until varA = 1000		'loop
		inc varA		'inc loop counter
		pause 10	'Wait command
		loop		'End of repeat loop 

		goto label_10

label_10:	let outpinsB = 0
		stop
[CODE]

Any comments would be welcome.
 

hippy

Technical Support
Staff member
We will investigate the REPEAT-LOOP block using greater than a byte value. In the meantime, to achieve 1000 loops you can use nested REPEAT-LOOP blocks to achieve 4 x 250 loops or similar. This should work in both simulation and on a physical PICAXE.
 

TerryRy

Member
Thanks hippy. I have already made the change. I have found the REPEAT-LOOP function to to produce some unexpected results particularly when there is a fair bit of code in the loop. I can't be more specific as I have generally found another way to do the function so that I can move on.
 
Top