Zoho Deluge - Pad with leading Zeros

There may be other articles out there documenting this but I can't keep trying to find these in Google so referring to my own website, this is a doddle for me to find each time.

I have to do this so often that it deserves an article. Though writing a whole page for this is probably unwarranted so I may rename this article later to common things I need to do in Zoho Deluge.

So going through the forums you may find the following example:
string padWithLeadingZeros(int finalStringLength, int startingNumber)
      return leftpad(toString(input.startingNumber), input.finalStringLength).replaceAll(" ", "0");

This looks like pretty old code and not wanting to cause offence, it isn't the JavaScript style or chain I like which appends the functions instead and is clearer for me personally to understand:
// I want 010

v_NextIndex = 10;
// yields 10

v_NextIndexStr = v_NextIndex.leftpad(3);
// yields " 10"

v_NextIndexStr = v_NextIndex.leftpad(3).replaceAll(" ", "0");
// yields "010"


Related Articles

Joes Revolver Map


Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Donate to Joel Lipman via PayPal

Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.