Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 538
  • Last Modified:

Pad Left with Zeros in Formula Language

In Lotus Notes R5 designer, we have a field that is defined as text, editable.  It represents a number.  We want it to be a full 8 characters, and if the user keys in less than 8 characters, we want to pad it automatically on the left with zeros.  Example: if user keys 12345, we want to automatically make it to be 00012345.  

What is the Formula Language (@...) command to pad left with zeros to a specific number of total characters?
0
blyons48
Asked:
blyons48
  • 2
  • 2
1 Solution
 
HemanthaKumarCommented:
Write this code in Input translation of the field,
max := 8;
len := @Length(num);
@if(len >= max; @left(num;max); @Repeat("0"; max-len) + num)

~Hemanth
0
 
SAKCommented:
Try:
@Right("00000000"+inputfld;8)


SAK
0
 
blyons48Author Commented:
SAK...your solution did the trick...simple and effective...thanks!
0
 
HemanthaKumarCommented:
What ?
0
 
blyons48Author Commented:
HermanthaKumar,
Ah!  I just tried your solution as well, and it works too, and even more sophisticated than SAK's simple one-line solution.  I guess I just jumped on the simpler looking one.  I apologize.  If I could somehow share the points between both of your good working solutions, I would.  But I've already submitted the Accept Answer.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now