SYMBOL

Hydroid

Senior Member
Hi,

I have a hunch that the answer's going to be no , but...

Is there any way to use ported inputs (if that's the correct term) with SYMBOL. I tried

Code:
symbol set_sw = porta pin0
symbol inc_sw = porta pin1
and get syntax errors.

Changing to just

Code:
symbol set_sw = pin0
symbol inc_sw = pin1
is OK, so it's the porta that's the trouble.

The normal (?) input pins (11-18) are all in use in my application.

Page 61 of manual 1 and page 202 of manual 2 explain the use of SYMBOL, but there's not any mention of ported inputs.

Is there any way to use SYMBOL with inputs from 'ported' pins ?

Regards, John.
 

lbenson

Senior Member
Your hunch is correct. It's awkward, but the best you can do is something like this:

symbol set_sw = pin0

if porta set_sw = 1 then ' test the switch
 

Hydroid

Senior Member
Your hunch is correct. It's awkward, but the best you can do is something like this:

symbol set_sw = pin0

if porta set_sw = 1 then ' test the switch
O.K., Thanks. Your idea would at least get the set_sw in the code which would help make it easier to read.

Would've been nice if SYMBOL worked with the 'port' part in there though.... next life maybe :)

John.
 

westaust55

Moderator
@Hydroid,

As explained in the PICAXE manual 2 page 6
where SYMBOLS are only able to be used as an
alias (alternate name) for variable and constant values.

Variables are b0, b1, b2, . . . or w0, w1, . . . etc
By default, these show up in pink in the PE.

Constants are fixed numbers such as 123, 45999, etc
By default, these show up in a very dark green/black clour

The Programming Editor has quite a number of pre-defined constants
such as those used for baudrates with SEROUT, etc, commands.

Hardware such as a port cannot be asigned an alias.
By default, hardware and keywords (FOR, NEXT, IF, THEN etc) are given a blue colour.

Remarks/comments as defined by semi-colon ( ; ) or Apostrophe ( ' ) are by default coloured light green

So if you type
Code:
[COLOR="YellowGreen"]; Our code starts here[/COLOR]

[COLOR="Magenta"]b0[/COLOR] = [COLOR="Blue"]N2400[/COLOR]

[COLOR="Magenta"]b1[/COLOR] = [COLOR="Magenta"]pin0[/COLOR]
[COLOR="Magenta"]b2[/COLOR] = [COLOR="Magenta"]pin2[/COLOR]

[COLOR="Magenta"]b9[/COLOR] = [COLOR="Green"]45[/COLOR]

[COLOR="Blue"]IF[/COLOR] [COLOR="Blue"]portA[/COLOR] [COLOR="Magenta"]pin1[/COLOR] = 0 [COLOR="Blue"]THEN[/COLOR]
[COLOR="Blue"]LET[/COLOR] [COLOR="Magenta"]b4[/COLOR] = [COLOR="Magenta"]b5[/COLOR] + [COLOR="Green"]3[/COLOR]
[COLOR="Blue"]ENDIF[/COLOR]

[COLOR="Blue"]PAUSE[/COLOR] [COLOR="Green"]1000[/COLOR]
The colour coding will help you understand what is a variable, a constant a keyword/hardware etc.

Trust this helps to give you a better understanding of when a SYMBOL can be used
 

tiscando

Senior Member
A while ago, I was suggesting:

Code:
[COLOR=blue]symboltext [/COLOR][COLOR=black]([/COLOR][COLOR=darkorange]set_sw[/COLOR][COLOR=black]) = [/COLOR][COLOR=black]([/COLOR][COLOR=blue]porta [/COLOR][COLOR=magenta]pin0[/COLOR][COLOR=black])[/COLOR]
 
[COLOR=blue]if [/COLOR][COLOR=darkorange]set_sw[/COLOR][COLOR=black]=[/COLOR][COLOR=darkslategray]1 [/COLOR][COLOR=blue]then high [/COLOR][COLOR=darkslategray]4 [/COLOR][COLOR=blue]endif[/COLOR]
Adding another colour (orange) for the symboltext definitions.

Or it may be called 'definetext' instead.
Is there any development on this?

http://www.picaxeforum.co.uk/showthread.php?t=10864&highlight=symboltext

How about having a 'symboltext' command which makes one particular text string be identified as another text string.
e.g.

symboltext {led2}={portc 6}

main:
high led2
...

(another colour setting added to the colour options)
 
Last edited:

westaust55

Moderator
What you refer to as "symboltext" or "definetext" is in reality an "alias" (ie just an alternate name) for a variable or constant.

But I think there has been no development on the line you have previously recommended. Some things may take a while for Rev Ed to action and some they may never action.
 

hippy

Ex-Staff (retired)
There is a degree of difficulty in colour highlighting symbol aliases as this has to be done dynamically, the entire program checked, parsed, and colours updated as required whenever anything changes. It can be done but can also be quite slow to do.

However, because command names, variables and other tokens are all coloured in certain ways, all that is left are words which would have been defined by symbol so they are given their own colour coding ( "default" ).

The only thing this doesn't provide is colour coding depending upon how the symbol alias was defined. This would require dynamic colour updating which could turn out to be quite a lot of work.
 
Top