Idea

Mischa Spelt avatar image
2 Likes"
Mischa Spelt suggested

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.

dot syntaxstringsformatting
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

No Comments

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.