Reputation: 143
When I try to format a string such as '%s%s' using a line of code like so:
format('%s%s', [x]);
I get an exception because you can't have multiple '%s' without using an array with the same amount of arguments such as:
format('%s%s', [x,x]);
However, I don't know how many '%s' I will have to format and therefore I don't know how long the array would have to be. I also only want '%s' assigned to only 1 value.
Is there a way in which you can use multiple '%s' and assign them all to the same index?
Upvotes: 2
Views: 2931
Reputation: 612954
As described in the documentation you can use an index specifier to identify the argument by a zero based index. The index specifier is written immediately after the %
and is followed by a :
.
Your example would be:
Format('%0:s%0:s', [x])
Upvotes: 8