Confused by Symbols

thunderace7

New Member
Hi.
Does this make sense, please?

Symbol outputline=b4
Symbol RedA=B.0
Let outputline=RedA
High outputline

It passes the syntax check but so does Symbol outputline=bit1 which can't be right, can it?

Thanks.
 

lbenson

Senior Member
"B.0" is a constant, value of zero (try SERTXD(#B.0) in simulator). In certain contexts, the picaxe interpreter takes this value to represent a pen (in a HIGH command, for instance). So "High outputline" is interpreted as "set the value of pin B.0 high".

Symbol outputline=bit1 is also valid. But HIGH OUTPUTLINE will set either B.0 or B.1 high depending on the value, (0 or 1) of bit1. Try
Code:
#PICAXE 20M2
Symbol outputline=bit1
bit1=1
sertxd(#bit1)
high outputline
bit1=0
sertxd(#bit1)
high outputline
 

Flenser

Senior Member
thunderace7,

From the manual "Symbols can be assigned to constant values, and can also be used as alias names for variables". This means that we are assigning the symbols as aliases for both the constant value and the variable name.

If it passes the syntax check the the syntax is valid.. You can check the syntax yourself by substituting the symbols in the code with the constant and variable aliases.

e.g. your code:
Code:
Symbol outputline=b4
Symbol RedA=B.0
Let outputline=RedA
High outputline
With the substitution done the becomes this valid syntax:
Code:
Let b4=B.0
High b4
 

thunderace7

New Member
I seemed to remember that someone had asked a similar question to this not long ago. I searched through the forum and found that the person who asked was me! It was almost exactly a year ago.
Can I get a new memory chip for my brain? The one I have is becoming increasingly less reliable.
 
Top