Use of the @@ operator
Thomas Stickney
Posts: 23
I am having a problem using the @@ operator. The simple code shown below has 13 text strings padded with periods.
Each string is 20 chars long. When the code is run the display shows garbled text·· If I reduce the length of each string
to 17 or fewer chars, the code works fine.
The expressions using @@ are shown with a '<
.
What is the right way to do this so long·strings can be printed?
Thanks in advance!
CON
_CLKMODE······· = XTAL1 + PLL16X
_XINFREQ······· = 5_000_000
rx__pin···· = 31·················· 'pin to receive a serial data signal (from prop plug)
tx__pin···· = 30·················· 'pin to send a serial data signal (to prop plug)
TAB········ = 9··················· 'used with Parallax
LF········· = 10·················· 'Serial Terminal
CR········· = 13·················· '
CLS········ = 16·················· '
VAR
BYTE str_select
OBJ
· DBG·········· : "FullDuplexSerial"
PUB·· Print_Months_Of_Year
· DBG.START (rx__pin, tx__pin, 0, 57600)
·
· WAITCNT(10 * CLKFREQ + CNT)
· DBG.TX (CLS)
· DBG.TX (CR)
· repeat str_select from 0 to 12
··· DBG.DEC (str_select)
··· DBG.TX (TAB)
··· DBG.DEC (STRSIZE(@@months_table[noparse][[/noparse]str_select << 1]))· '<----
··· DBG.TX (TAB)
··· DBG.STR (@@months_table[noparse][[/noparse]str_select << 1])··'<----
··· DBG.STR (STRING(LF, CR))
· DBG.STR (STRING("End", LF, CR))
DAT
months_table
······· WORD· @nomnth
······· WORD· @mnth1
······· WORD· @mnth2
······· WORD· @mnth3
······· WORD· @mnth4
······· WORD· @mnth5
······· WORD· @mnth6
······· WORD· @mnth7
······· WORD· @mnth8
······· WORD· @mnth9
······· WORD· @mnth10
······· WORD· @mnth11
······· WORD· @mnth12
·······
nomnth· BYTE· "
...........",0
mnth1·· BYTE· "January.............",0
mnth2·· BYTE· "Febuary.............",0
mnth3·· BYTE· "March...............",0
mnth4·· BYTE· "April...............",0
mnth5·· BYTE· "May.................",0
mnth6·· BYTE· "June................",0
mnth7·· BYTE· "July................",0
mnth8·· BYTE· "August..............",0
mnth9·· BYTE· "September...........",0
mnth10· BYTE· "October.............",0
mnth11· BYTE· "November............",0
mnth12· BYTE· "December............",0
Each string is 20 chars long. When the code is run the display shows garbled text·· If I reduce the length of each string
to 17 or fewer chars, the code works fine.
The expressions using @@ are shown with a '<
.
What is the right way to do this so long·strings can be printed?
Thanks in advance!
CON
_CLKMODE······· = XTAL1 + PLL16X
_XINFREQ······· = 5_000_000
rx__pin···· = 31·················· 'pin to receive a serial data signal (from prop plug)
tx__pin···· = 30·················· 'pin to send a serial data signal (to prop plug)
TAB········ = 9··················· 'used with Parallax
LF········· = 10·················· 'Serial Terminal
CR········· = 13·················· '
CLS········ = 16·················· '
VAR
BYTE str_select
OBJ
· DBG·········· : "FullDuplexSerial"
PUB·· Print_Months_Of_Year
· DBG.START (rx__pin, tx__pin, 0, 57600)
·
· WAITCNT(10 * CLKFREQ + CNT)
· DBG.TX (CLS)
· DBG.TX (CR)
· repeat str_select from 0 to 12
··· DBG.DEC (str_select)
··· DBG.TX (TAB)
··· DBG.DEC (STRSIZE(@@months_table[noparse][[/noparse]str_select << 1]))· '<----
··· DBG.TX (TAB)
··· DBG.STR (@@months_table[noparse][[/noparse]str_select << 1])··'<----
··· DBG.STR (STRING(LF, CR))
· DBG.STR (STRING("End", LF, CR))
DAT
months_table
······· WORD· @nomnth
······· WORD· @mnth1
······· WORD· @mnth2
······· WORD· @mnth3
······· WORD· @mnth4
······· WORD· @mnth5
······· WORD· @mnth6
······· WORD· @mnth7
······· WORD· @mnth8
······· WORD· @mnth9
······· WORD· @mnth10
······· WORD· @mnth11
······· WORD· @mnth12
·······
nomnth· BYTE· "
...........",0
mnth1·· BYTE· "January.............",0
mnth2·· BYTE· "Febuary.............",0
mnth3·· BYTE· "March...............",0
mnth4·· BYTE· "April...............",0
mnth5·· BYTE· "May.................",0
mnth6·· BYTE· "June................",0
mnth7·· BYTE· "July................",0
mnth8·· BYTE· "August..............",0
mnth9·· BYTE· "September...........",0
mnth10· BYTE· "October.............",0
mnth11· BYTE· "November............",0
mnth12· BYTE· "December............",0
Comments
I think you could access the months_table directly as a word array if you defined it·as follows:
Dave
Post Edited (Dave Hein) : 7/23/2010 8:19:59 PM GMT
@nmonth + 20*str_select
or better ... define a constant which holds the stringlength and use that ... makes it a bit more flexible.
Calculating saves 13 words of valuable RAM in this case ;o)
....
Or use the table and create the dots via program, which·saves even more memory.
Post Edited (MagIO2) : 7/23/2010 8:49:17 PM GMT