cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

String format function

String format function

Now that FlexScript has a proper string class, maybe it would be nice to add a string.format function.

I often still find myself writing code like

string message = "Object " + object.name + " changed to product " +
	string.fromNum(object.Product) + " at time " + string.fromNum(Model.time, 3, 3) + ".";
msg("Changeover complete", message);

It would be cool if I could replace this by

string message = string.format("Object %s changed to product %d at time %3f", 
	object.name, object.Product, Model.time);
msg("Changeover complete", message);

Implementation could be as easy as taking all the arguments and just stuffing them into sprintf, although I'm not sure it's straightforward like that when everything is passed as Variants.

This would come in handy in a variety of situation such as msg() calls, mpt(), constructing SQL statements, creating logs, objectinfo, ... and all other places where you need to pass a single string.

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea