Error message

TTOP

New Member
Have the Picaxe Editor 6 v 6.0.8.0 installed on Windows 7, wrote about 15 programs so far with no issues. Started writing code and checked for syntax errors after writing each line, then when I wrote - if b0=0 then : b3 = 0 elseif b0 = 1 then b3 = 0 elseif b0 = 2 then b3 = 0 elseif b0 = 3 then b3 = 0 elseif b0 = 4 then b3 = 4 elseif ........ when i get to around elseif b0 = 45 then b3 = 250 then the following message box appears "Syntax Check Failed X If b0 = 0 then : b3 = 0 elseif b0 = 1 then b3 = 0 elseif b0 = 2 then b3 = 0 elseif t Syntax Error on line 7 at position 1 "C:\users\TC\AppData\Local\Temp\e34z3Tw ERROR: Internal Error: match called with wrong token". Then the message box appears "Picaxe is not responding Close the program" Then I go to the other programs in the Editor and they will run. if I write the code as - if b0 = 0 then : b3 = 0 endif if b0 = 1 then : b3 = 0 endif if b0 = 2 then : b3 = 0 endif if b0 = 3 then : b3 = 0 endif if b0 = 4 then : b3 = 4 ... all the way to if b0 = 60 then b3 = 250 b5 = 84 endif... then there are no problems when I syntax check and I can finish the program and run it. Can the problem be using to many elseifs or is it a Editor problem or computer problem? Thanks.
 

Technical

Technical Support
Staff member
Your post is not particular clear - did you write all these statements on one extremely long line?
You should break each statement up with : on a long line. However this type of coding would be much easier to read as

Code:
[color=Blue]Select case [/color][color=Purple]b0[/color]
[color=Blue]case [/color][color=Navy]0[/color][color=Black],[/color][color=Navy]1[/color][color=Black],[/color][color=Navy]2[/color][color=Black],[/color][color=Navy]3
      [/color][color=Purple]b3 [/color][color=DarkCyan]= [/color][color=Navy]0[/color]
[color=Blue]case [/color][color=Navy]4
      [/color][color=Purple]b3 [/color][color=DarkCyan]= [/color][color=Navy]4[/color]
[color=Blue]end select[/color]
 

TTOP

New Member
Started learning the Picaxe 2 weeks ago. Do not know all of the commands yet. Technical gave example code for the select case command and I looked at it and tried it but noticed something.
This code uses 84 bytes:
if b0 = 0 then : b3 = 0 endif
if b0 = 1 then : b3 = 0 endif
if b0 = 2 then : b3 = 0 endif
if b0 = 3 then : b3 = 0 endif
if b0 = 4 then : b3 = 4 endif
if bo = 5 then : b3 = 16 endif
if b0 = 6 then : b3 = 28 endif
if b0 = 7 then : b3 = 40 endif
if b0 = 8 then : b3 = 52 endif
if b0 = 9 then : b3 = 64 endif
if b0 = 10 then : b3 = 76 endif

This code uses 106 bytes
select case b0
case 0, 1, 2, 3
b3 = 0
case 4
b3 = 4
case 5
b3 = 16
case 6
b3 = 28
case 7
b3 = 40
case 8
b3 = 52
case 9
b3 = 64
case 10
b3 = 76
end select
Both programs do the same thing but the select case command uses more memory but you do less typing. How do you determine which one to use?
 

Technical

Technical Support
Staff member
There is never just one way to write code, so it comes down to experience and personal preference and readability.

The most efficient way to do this is actually:

lookup b0,(0,0,0,0,4,16,28,40,52,64.76),b3
 

TTOP

New Member
I was searching around and came across a post that said EEPROM and READ commands take less bytes then the LOOKUP command. Anything on this ?
 
Top