I'd like to know if you can use String.Format in functions in the same way that Display() works.
Here's the very basic function:
function Message (String text) {
dostuff;
}
and here's how it's used with String.Format
Message (String.Format ("bla bla bla %d",stat));
With Display, you don't have to enter String.Format, and that's how I'd like my function to work.
It's a small problem that I hardly ever run into. Still, if it's possible...
I don't think there's a way of doing it unless you know for sure what the type of the variable is (or if there's multiple in which order they appear).
If it's always an int, you could make the variable optional, like so:
import function Message(String text, int stat = -1); //set the default value to something you wouldn't use when calling the function
function Message(String text, int stat) {
if (stat != -1) text = String.Format(text, stat);
dostuff(text);
}
In most cases simply using String.Format within the function call would be simpler imho.
I thought about using the int, but it's easier as you say to just use String.Format when calling the function. It's very rarely I need String.Format really, would just have been a luxury :)
If you're looking through the manual entries, any of the functions which list ... as the final parameter (following a const string parameter of course) can use string formatting. Unfortunately we can't utilize ... as a parameter. Last I checked you can use it in your functions, but there's no way to actually access the additional data passed to the function, rendering it useless.
So, we just use String.Format where necessary. :P