TXT Row Column insert ?

Non-platform specific questions.

TXT Row Column insert ?

Postby HiTemp » Fri Aug 19, 2011 4:03 pm

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 ");
User avatar
HiTemp
 
Posts: 4
Joined: Sat Aug 13, 2011 5:43 pm
Location: Poland
Score: 0 Give a positive score

Re: TXT Row Column insert ?

Postby skydereign » Fri Aug 19, 2011 7:39 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: TXT Row Column insert ?

Postby HiTemp » Sat Aug 20, 2011 8:13 am

skydereign thenx
I was looking for this code.
User avatar
HiTemp
 
Posts: 4
Joined: Sat Aug 13, 2011 5:43 pm
Location: Poland
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest