javascript - Utilities.formatString() New Apps Script method, not working as intended -
i using new method: utilities.formatstring()
in google documentation says similar sprintf %-style.
i searched , read this article sprintf in php.
i cannot seem work intended. meant pad 8 character string 4 leading zeros. know there other ways this, trying handle on sprintf / formatstring thing.
var noformat = "12345678"; var formatted = utilities.formatstring("%012s", noformat);
i expected var formatted equal "000012345678". debugger tell me formatted = 0, or throws error..
i confused.
try :
function xxx(){ var noformat = '12345678' var formatted = utilities.formatstring("%012d", noformat); logger.log(formatted) }
the different parameters can used easy find on web, here example explains how argument must evaluated in php usage same.
logger result :
Comments
Post a Comment