Why does FString Append in loop use numbers from previous loop?

Hi,

I think the problem lies with the
Append function, but I can’t figure
out why it does that?

there is no problem, it is just how Append it works.

FString MyString = "ABC";
MyString.Append("D");

MyString is now “ABCD”

If you want a new string as output, then use +

FString MyString = "ABC";
FString NewString = MyString + "D";

MyString is now “ABC”, NewString is “ABCD”

I created a loop to create a chess board like system to save locations, so vector under key number A0 should save vector location (0,0,0), key A1 should save vector location (0,1000,0) and so on. The loop mostly works, however the keys are saved like A123 instead of just A3. So it prints out all y values and not just the last one. Also, once it switches to the next row, in this case the B row, then it clears itself and starts form just B0 again. So what I want is that it saves just the last y number and not all of them, for example in picture 3, instead of A1234 I want just A4.

Does it temporary save BoardCharachters[x] A0 when it’s in the first loop, and then in the second loop it just adds onto that? But I never said that “BoardCharachters[x] = BoardCharachters[x]. Append(y)” I just said “BoardCharachters[x]. Append(y)”, right?

I think the problem lies with the Append function, but I can’t figure out why it does that?

The variables:

344448-snimka-zaslona-853.png

The loop:

Printed line that shows how the key looks:

344449-snimka-zaslona-857.png

Oh ok, so I just didn’t understand how it was supposed to work, sorry and thank you! :slight_smile: