Page 1 of 1

Text with variables

PostPosted: Thu Nov 15, 2007 1:50 pm
by asmodeus
How can I put variables in the text with the script editor?

Re: Text with variables

PostPosted: Fri Nov 16, 2007 12:09 am
by Game A Gogo
Code: Select all
strcpy(destination, "Input text here\n");


If it gives out an error, or just does not work, I think you need to inverse the two things inside the command.

Re: Text with variables

PostPosted: Fri Nov 16, 2007 1:12 pm
by asmodeus
Sorry, I don't really understand it. I want to have something like that:
Code: Select all
int var = 10;
strcpy(text, "My variable: ");
strcat(text, var);

And then there should be a text: "My varibale: 10".

Re: Text with variables

PostPosted: Fri Nov 16, 2007 1:40 pm
by makslane
Try:

Code: Select all
sprintf(text, "My variable: %d", var);

Re: Text with variables

PostPosted: Fri Nov 16, 2007 3:29 pm
by asmodeus
Thank you. But I need a bit more. For example this: "Game File 1: 16% (new line) Game File 2: 14%". The numbers 16 and 14 are the variables. How can I code this?

Re: Text with variables

PostPosted: Fri Nov 16, 2007 3:41 pm
by makslane
Try this:
Code: Select all
sprintf(text, "Game File 1: %d%%\nGame File 2: %d%%", var1, var2);

Re: Text with variables

PostPosted: Fri Nov 16, 2007 4:02 pm
by asmodeus
Thank you! That works! :D