Can the Propeller support string variables or other useful string operations?
ElectricAye
Posts: 4,561
Hi all,
I've been looking for a way to "increment" a string. In other words, I'm looking for a way to make string Name1 become string Name2, then Name2 become Name3, etc. in a loop thousands of times.
Does anyone know if the Propeller can do that? via Spin or assembly or some fancy-schmancy technique?
thanks,
Mark
PS.
(I asked a very similar question about incrementing SD card files earlier, but I thought that it would be better to re-ask this question in a more general way rather than be so specific about SD files.)
I've been looking for a way to "increment" a string. In other words, I'm looking for a way to make string Name1 become string Name2, then Name2 become Name3, etc. in a loop thousands of times.
Does anyone know if the Propeller can do that? via Spin or assembly or some fancy-schmancy technique?
thanks,
Mark
PS.
(I asked a very similar question about incrementing SD card files earlier, but I thought that it would be better to re-ask this question in a more general way rather than be so specific about SD files.)
Comments
Thanks, Mike, it's nice to know that it can be done. Now, when you say "add" a digit to a string, how is that done in Spin? How in Spin do you set up arrays for characters?
I'm still perplexed,
Mark
sdfat.popen(string("Name", Number, ".csv"), "w")
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It might be the Information Age but the Eon of Ignorance has yet to end.
Do you want to do this?
r := sdfat.popen(@buffer, "r")
Then load buffer with Name1, Name2, and so on.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
Look at the chapter on BYTE in the manual. You declare a byte array called foo for example of size 6 with
You can initialize it to "N0000" and increment it as follows
You'd call this with: increment(@foo,6)
Ah-haaaa...
that's the kind of stuff I'm looking for. I'll have to ponder this today.
Thanks you guys!
Mark
As usual, your suggestions are proving to be extremely valuable!
For the record, though, in case anyone else is following this thread, the bytemove line needs an @ before foo.
It should read,
bytemove(@foo,string("N0000"),6)
Thanks again!
Mark