How do I make this work - If b1 >= 29 and b1<= 31 then gosub Try1

Natalie Wilkie

New Member
Hi all,

I am using a 08m chip and trying to do this:

"If b1 >= 29 and b1<= 31 then gosub Try1"

It keeps coming up with a syntax error.

Thanks for any help
cheers
Nat
 

alexthefox

Senior Member
i have find this solution:
up:
if b1=29 or b1=30 or b1=31 then
goto Try1
else
goto up
endif

Try1:
.......
......
......
 

Dippy

Moderator
Well, it works for me.

picaxe 08m
b1=0

StartLoop:
If b1 >= 29 and b1<= 31 then gosub Try1
pause 300
b1=b1+1
goto startloop

Try1:
b1=0
return

The above ran in simulator fine.
Have you got some weird options set?

View/Options/Editor/Compiler .. tick the 'Enhanced' option.
 

jodicalhon

New Member
Your original syntax looks ok, Nat. Do you have the 'enhanced compiler' option flagged?

Ooer...sorry, Dippy - you're a faster typer than me.
 

Natalie Wilkie

New Member
Thanks for all your responses.

After everyone said it ran for them in their simulator I found I had an invalid character in the sub name (which I changed when I posted) so I inadvertently fixed it when I changed the sub name to try1.

Thanks again
Nat
 
Top