string format
Charles Hartman
charles.hartman at conncoll.edu
Sun Aug 28 07:59:28 EDT 2005
On Aug 28, 2005, at 5:01 AM, Alex Tweedly wrote:
>>> . . . the particular problem of adding spaces after a string to
>>> fill it out to a specified length.
>>
>> It would work if the "incantation" argument of format() would
>> accept a variable name, but I can't find a way to make it do
>> that . . .
>
> You can't do format("%<myVar>d", otherVar).
>
> But you can do
> put "%" & myVar & "d" into temp
> format(temp, otherVar)
I'm not sure you can. This in the message box
put "string" into s; put "%" & (20 - length(s)) & "d"into tTmp;
put format(tTmp, s)
produces
-1879024420
(with a total length of 14), though 'put tTmp' produces '%14' as
expected. Did I miss something?
Anyway, the solution in this direction that I was thinking of is
presumably too baroque to be useful -- something like
put " " into s
put "%" & 20 - length(s) & "d" into tTailFmt
put myString & format(tTailFmt, s)
Charles
More information about the use-livecode
mailing list