Format object help required (SOLVED)
Peter Verkaik
Posts: 3,956
Attached are my Format object and Format test program.
I load the test program into a spin stamp and output strings
via the propclip.
The mainloop is
· repeat
'··· fmt.sprintf(buffer,string("%c"),"Z")
··· fmt.sprintf(buffer,string("%s"),string("ABCD"))
'··· fmt.sprintf(buffer,string("%d"),16)
'··· fmt.sprintf(buffer,string("%i"),16)
'··· fmt.sprintf(buffer,string("%b"),16)
'··· fmt.sprintf(buffer,string("%o"),16)
'··· fmt.sprintf(buffer,string("%u"),16)
'··· fmt.sprintf(buffer,string("%x"),16)
··· debugHex2(buffer)
··· waitcnt(clkfreq / 1000 * 100 + cnt)
The idea is to enable just one of the sprintf statements.
For %c I get 5A (hexvalue of "Z") in a rapid tempo.
For %s I get 41424344, but there is quite a delay between successive outputs.
All the other output nothing. It looks Format.bprintf never returns.
Strange, as this is the exact code I use on the Javelin and there it works.
Can anybody spot any (obvious) error? As this is my first propeller project it is quite
possible I did something wrong with the pointers.
regards peter
Post Edited (Peter Verkaik) : 12/14/2007 10:00:46 AM GMT
I load the test program into a spin stamp and output strings
via the propclip.
The mainloop is
· repeat
'··· fmt.sprintf(buffer,string("%c"),"Z")
··· fmt.sprintf(buffer,string("%s"),string("ABCD"))
'··· fmt.sprintf(buffer,string("%d"),16)
'··· fmt.sprintf(buffer,string("%i"),16)
'··· fmt.sprintf(buffer,string("%b"),16)
'··· fmt.sprintf(buffer,string("%o"),16)
'··· fmt.sprintf(buffer,string("%u"),16)
'··· fmt.sprintf(buffer,string("%x"),16)
··· debugHex2(buffer)
··· waitcnt(clkfreq / 1000 * 100 + cnt)
The idea is to enable just one of the sprintf statements.
For %c I get 5A (hexvalue of "Z") in a rapid tempo.
For %s I get 41424344, but there is quite a delay between successive outputs.
All the other output nothing. It looks Format.bprintf never returns.
Strange, as this is the exact code I use on the Javelin and there it works.
Can anybody spot any (obvious) error? As this is my first propeller project it is quite
possible I did something wrong with the pointers.
regards peter
Post Edited (Peter Verkaik) : 12/14/2007 10:00:46 AM GMT
spin
13K
Comments
The attached Format.spin is updated.
Unfortunately, the issue still stands.
regards peter
For most calls I needed to use @buffer instead of buffer alone.
Coming from C where the array name is the address and equal to &arrayname[noparse][[/noparse]0],
in Spin the array name by itself equals arrayname[noparse][[/noparse]0]. Not the best of choice
but so be it.
Attached are the updated object and test program.
regards peter
Added test for sscanf and documentation for sscanf and sprintf.
Added support for \\, \t, \n, \r in printf format string.
regards peter
Post Edited (Peter Verkaik) : 12/14/2007 9:00:28 AM GMT