macro not passing syntax

johnlong

Senior Member
Hi
On a recient thread I posted Hippy wrote a macro for a word variable
I have tried to represent it for use with just a single variable but it will not
pass syntax.
I have reread Hippys post on using macros but can not see why it will not work
but the word one does
PICAXE Macros
Code:
symbol double=w12
symbol single=b8
symbol QT=34
#Macro SerTxdNumber( wVar )
  BinToAscii wVar, b0,b1,b2,b3,b4
  If b0 = "0" Then
    b0 = " "
  End If
    hserout 0,(QT,b0,b1,".",b2,b3,b4,QT,$ff,$ff,$ff)
    hserflag=0
    hserptr=0
#EndMacro

#Macro Singular ( var )
    hserout 0,(QT,#var,QT,$ff,$ff,$ff)
    hserflag=0
    hserptr=0
#EndMacro
hsersetup   B9600_8, %01
double=1023
single=40
do

    hserout 0,("double.txt=")SerTxdNumber(double)
    hserout 0,("single.txt=") Singular (single)

loop
is it not possible for some reason that the use of var in this instance is not allowed
regards john
 

Buzby

Senior Member
If you use the pre-processor display option it lets you see exactly what the macro expansion produces.

This makes it much easier to see where you have a macro error.

23445
 

hippy

Technical Support
Staff member
#Macro Singular ( var )

It seems to be a result of having a space between the macro name and the opening bracket. Removing the space fixes things ...

#Macro Singular( var )

What it seems to have done is treat "#Macro Singular ( var )" as a #DEFINE, so where "Singular" was appearing it was replacing that with "( var )" and hence the syntax error.
 

johnlong

Senior Member
Hi
have tried both the pre processor report shows the macro called but the variable is at the end of
the process , seems to be splitting up the the command
REPORT created by syntax check
**************
symbol double=w12
symbol single=b8
symbol QT=34



hsersetup B9600_8, %01
double=1023
single=40
do

hserout 0,("double.txt=")
BinToAscii double, b0,b1,b2,b3,b4
If b0 = "0" Then
b0 = " "
End If
hserout 0,(QT,b0,b1,".",b2,b3,b4,QT,$ff,$ff,$ff)
hserflag=0
hserptr=0

hserout 0,("single.txt=")(var)
bintoascii var,b0,b1,b2
If b0 = "0" Then
b0 = " "
End If
hserout 0,(QT,b0,b1,".",b2,QT,$ff,$ff,$ff)
hserflag=0
hserptr=0
(single)

loop
 

Attachments

Top