Page 1 of 1

TXT Row Column insert ?

PostPosted: Fri Aug 19, 2011 4:03 pm
by HiTemp
How to insert text into the single actor in a particular position

column 1 column 2
Row1 X
Row2 X
Row3 X

These examples obviously do not work

char tab[2][3];
tab[1][1]="X";
Actor.text <- tab[1][1];

or
strcpy(bbb.text[1][2]." X ");

Re: TXT Row Column insert ?

PostPosted: Fri Aug 19, 2011 7:39 pm
by skydereign
You should be using sprintf. It allows you to format the string that you are setting the text to.
Code: Select all
sprintf(text, "%-8s%-8s\n%-8s%-8s", "string1", "string2", "string3", "string4");

That example uses strings like in yours, but you can change them to store characters, integers, whatever you want. But to explain sprintf, it takes the format (the string with the %'s in it) and inserts text into it based off what the format is. So, each %-8s will look for a string variable after the format, and insert it in. Normally you just have %s, but since you want to have columns, the -8 part specifies that the column width should be 8 characters long, and the negative means it should align on the left (leaving the minus out will make it align to the right of the column). The \n is used to signify a new line, so keep that in mind when formatting. That's a bit cursory explanation of sprintf, so if you are having trouble do ask.

Re: TXT Row Column insert ?

PostPosted: Sat Aug 20, 2011 8:13 am
by HiTemp
skydereign thenx
I was looking for this code.