code modification r: Ibutton

nickwoodrow

New Member
Hi all, Happy New year!
I've just ordered an Ibutton and reader from the Picaxe Rev-ed store and downloaded the code from the Specification data on their page. (see below). I notice it is for Picaxe-08M I have the more up to date O8m2 this is also on the setings for Picaxe editor. My problem is when I paste the code and check syntax i am getting the following message

Loop:
Syntax error on line 6 at/before position 4
Error: Loop without Do

Could any body help out please. TIA

Code:
main:
let b6 = 0 ' reset family code to 0
low 0 ' LED off
low 1 ' output off
loop:
toggle 0 ' LED on or off
if pin3 = 0 then open ' switch pushed
pause 250 ' wait
readowsn 4 ' read serial number on input4
if b6 <> 0 then test ‘ ibutton detected
goto loop
' ibutton detected so check code
' if wrong code jump back to start
test:
sound 2,(50,50) ' beep
high 0 ' probe LED on
if b6 <> $FF then main ' !!! modify all these
if b7 <> $00 then main ' !!! to your unique
if b8 <> $11 then main ' !!! serial number
if b9 <> $22 then main
if b10 <> $33 then main
if b11 <> $44 then main
if b12 <> $55 then main
if b13 <> $CC then main
'Everything is ok so switch output on for 5 seconds
open:
sound 2,(100,50) ' beep
high 1 ' LED on
high 2 ' output on
pause 5000 ' wait 5 seconds
goto main
 

lbenson

Senior Member
"LOOP" is a reserved word, as in DO: LOOP (see manual 2).

Change the label to something different.

Or better, avoid use of GOTO by changing "loop:" to "DO" and "GOTO LOOP" to just LOOP, making it a proper "do loop".
 

nickwoodrow

New Member
Wow, Thank you. Have done that and it appears to work. Will wait for the postie to bring the goodies and try for real. Thanks again
 

inglewoodpete

Senior Member
Explanation: In the earlier days of PICAXE, the words "DO" and "LOOP" could be used as labels or variable names. When "DO" and "LOOP" were introduced as commands, they could no longer be used as labels etc. As lbenson has advised, your aging piece of code needed updating to stop the (modern) compiler getting confused.
 

nickwoodrow

New Member
Explanation: In the earlier days of PICAXE, the words "DO" and "LOOP" could be used as labels or variable names. When "DO" and "LOOP" were introduced as commands, they could no longer be used as labels etc. As lbenson has advised, your aging piece of code needed updating to stop the (modern) compiler getting confused.

Thank for your reply. It might help the less informed if Picaxe updated their example code for the ibutton project pack! Thanks again.
 

hippy

Senior Member
It might help the less informed if Picaxe updated their example code for the ibutton project pack!
Please accept our apologies for the code not immediately working. There are unfortunately issues in keeping printed leaflets and even legacy PDF's up to to date.

The example code provided with PE6 has previously been corrected and will compile without issue once the 'code to match' has been updated and the warning to do that has been removed ...

File -> Open Samples -> BASIC -> AXE109 - iButton Lock
 
Top