understanding string manipulations
NamNori
Posts: 4
Hello:
In attempting to do some string manipulation, I quickly figured out that I'm not sure of what I'm doing.
I had wanted to concatenate 2 strings into a single variable, and found other posts on the forum showing how to do so with some ByteMove statements. But it's not working for me; obviously I went south somewhere here... I was attempting to simply concatenate src1 with src2 into dest. My first ByteMove statement works, but the second one doesn't do anything. And by putting the addresses out to the serial terminal, I see that when it's all done, both the dest and the src1 variables have the same address? Doesn't seem right to me. I've played with adding/removing the "@" to/from the variables within ByteMove, and it only seems to work with @ in place like it is below.
I'm probably not understanding some fundamental aspect here, and am hoping somebody can clear up my misunderstanding.
thanks!
-marc
In attempting to do some string manipulation, I quickly figured out that I'm not sure of what I'm doing.
I had wanted to concatenate 2 strings into a single variable, and found other posts on the forum showing how to do so with some ByteMove statements. But it's not working for me; obviously I went south somewhere here... I was attempting to simply concatenate src1 with src2 into dest. My first ByteMove statement works, but the second one doesn't do anything. And by putting the addresses out to the serial terminal, I see that when it's all done, both the dest and the src1 variables have the same address? Doesn't seem right to me. I've played with adding/removing the "@" to/from the variables within ByteMove, and it only seems to work with @ in place like it is below.
I'm probably not understanding some fundamental aspect here, and am hoping somebody can clear up my misunderstanding.
thanks!
-marc
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ PST : "Parallax Serial Terminal" VAR byte dest[10] byte src1 byte src2 PUB Main PST.Start(115200) PST.Home PST.Clear Src1 := String("abc") Src2 := String("def") PST.Str(String("Src1: ")) PST.Str(src1) PST.NewLine PST.Str(String("Src2: ")) PST.Str(src2) PST.NewLine PST.Hex(src1, 2) PST.NewLine PST.Hex(src2, 2) PST.NewLine ByteMove(@dest, @src1, StrSize(src1)) ByteMove(@dest + StrSize(src1), @src2, StrSize(src2) + 1) PST.Str(String("Dest: ")) PST.Str(dest) PST.NewLine PST.Hex(dest, 2) PST.NewLine PST.Hex(src1, 2)
Comments
a longer time ago I made a oo-sheet explaining stringmanipulation
see attachment
best regards
Stefan
Hi Stephan,
Can't open the file.
My apologies for being a pain about this - but could you post that in a more accessible form?
Text maybe?
No. The main purpose is to show how strings are handled and what pointers are. If you're asking this way I guess you found bugs.
Please report them
best regards
Stefan