Two Strings, One Message

Started by Valentine, Mon 26/01/2009 17:28:58

Previous topic - Next topic

Valentine

I'm trying to use DrawStringWrapped to display a message, but I'm having problems. I'm currently using;

surface.DrawStringWrapped(50, 50, 700, 1, eAlignCentre, "%s talks to %s.", Name1, Name2);

but that returns the error 'Error (line 184): wrong number of parameters in call to 'DrawingSurface::DrawStringWrapped'

The code DOES however work for Display, when I used; Display("%s talks to %s.", Name1, Name2);}

The manual says "You can insert the value of variables into the message. For more information, see the string formatting section." so I would have thought they would have worked the same way.

What am I doing wrong? Thanks!

Akatosh

Some commands don't support formatted strings like that. What you're looking for is something like

Code: ags

surface.DrawStringWrapped(50, 50, 700, 1, eAlignCentre, String.Format("%s talks to %s.", Name1, Name2));

monkey0506

Just to be clear, unless the manual entry specifically states that the function supports string formatting, you'll need to use String.Format.

Also, in the calltip prompt which lists all the parameters, these functions (which support string formatting) have an additional parameter listed as "...".

SMF spam blocked by CleanTalk