Format function on LiveCode 6.5.1

Mark Wieder mwieder at ahsoftware.net
Fri Jan 3 04:04:30 CET 2014


Alejandro-

Thursday, January 2, 2014, 3:21:06 PM, you wrote:

> Hi All,

> Could you post your results of these code snippets?

> Write in the message box:
> put format("%04s",17)
> Write down the result and test this:
> put format("%04d",17)

> Post both results, your LiveCode version 
> and your Operating System.

The documentation is a bit ambiguous on this, but I believe the linux
implementation does the right thing (my results agree with Martin's,
in that the result of 17 is padded with two leading spaces). The OSX
implementation just seems wrong to me.

>From the documentation:

String:
%[charLength]s
The corresponding value is unchanged, except that if a charLength is
specified, if the string is shorter than the charLength, enough
leading spaces are added to make it charLength characters long. If the
length of the string is equal to or greater than the charLength, it is
unchanged. For example, the incantation %3s transforms "H" to "  H".

What are you wanting to happen here?

-- 
-Mark Wieder
 ahsoftware at gmail.com




More information about the use-livecode mailing list