More String Concaternation
Heavy
Posts: 6
Ok so I'm new at this propeller stuff. I want to join 2 strings into a third string, but I have failed miserably at all attempts. Here's my code.
Here's the relevant parts of my code:
VAR
·· byte nextfile·
·· byte newfile[noparse][[/noparse]8]
·· byte fileext
PUB start· | cog_ID
fileext := String(".csv")
nextfile := String("test")
bytemove(@newfile ,@nextfile,strsize(nextfile))
bytemove(@newfile + 4,@fileext,strsize(fileext) + 1)
This is what I get on the Serial terminal:
nextfile =test
fileext =
newfile =test
What I want is for newfile to be the combination of nextfile and fileext.
Any help would be appreciated. Thanks
·
Here's the relevant parts of my code:
VAR
·· byte nextfile·
·· byte newfile[noparse][[/noparse]8]
·· byte fileext
PUB start· | cog_ID
fileext := String(".csv")
nextfile := String("test")
bytemove(@newfile ,@nextfile,strsize(nextfile))
bytemove(@newfile + 4,@fileext,strsize(fileext) + 1)
This is what I get on the Serial terminal:
nextfile =test
fileext =
newfile =test
What I want is for newfile to be the combination of nextfile and fileext.
Any help would be appreciated. Thanks
·
Comments
-Phil
How would I go about joining the two strings if nextfile is a number. I've dowloaded Numbers.spin , but I can't seem to get Num.ToStr to work.
Post Edited (Heavy) : 7/5/2010 11:22:05 PM GMT
This uses the stringbuffer in the numbers object, which anyway reserves memory, for the resulting string. nextfile points to this string.
123 is the number to convert, you can also use a variable instead.
nextfile and fileext are long variables
Andy