Numbers formatted with leading zeros?

  • Follow


Hi all,

I want to have a field which is a serial number, formatted so that it
is always x number of digits with zeros filling in to the left like
"00462", "0003" etc.

I have no idea how to do this without a tremendous kluge, and I welcome
any and all suggestions.

My kluges are (I'll spare you the pseudocode):

1. Make the number into a string, count characters, concatenate "0"s to
the left until full. wash rinse repeat.

or

2. Make an "odometer" with five (or however many) individual variables:
x1, x2, x3, x4, x5; increment until x1 == 9, rollover over to x2 and
reset x1 to 0. repeat for each of the subsequent variables. Would have
to line them up to look like one number.

OK, problems: #1 leaves me with a string, not a number; #2 leaves me
with five individual numbers, and besides it is _way_ too complicated.

I'm sure this is something I missed in high-school math ... and  I ran
a check on the archives but didn't find anything.

Thanks in advance,

jon

-- 
ls: .sig: No such file or directory
0
Reply fabian (7) 1/11/2005 9:11:40 PM

I'm confused over how many digits you are looking for, or if it might be 
different for every entry.

If you always want the final number to have five digits, for example, 
make the field a text field with auto-enter serial number with the 'next 
serial number' set to be 00001.  This will increment correctly and will 
always have five digits.  It must be a text string, as numbers cannot 
have leading zeroes.

Or to take any length number and add leading zeroes to a certain length:
	right("00000" & YourNumber, 5)
The calc result must be set to be text, for the same reason as above.


jon fabian wrote:
> Hi all,
> 
> I want to have a field which is a serial number, formatted so that it
> is always x number of digits with zeros filling in to the left like
> "00462", "0003" etc.
> 
> I have no idea how to do this without a tremendous kluge, and I welcome
> any and all suggestions.
> 
> My kluges are (I'll spare you the pseudocode):
> 
> 1. Make the number into a string, count characters, concatenate "0"s to
> the left until full. wash rinse repeat.
> 
> or
> 
> 2. Make an "odometer" with five (or however many) individual variables:
> x1, x2, x3, x4, x5; increment until x1 == 9, rollover over to x2 and
> reset x1 to 0. repeat for each of the subsequent variables. Would have
> to line them up to look like one number.
> 
> OK, problems: #1 leaves me with a string, not a number; #2 leaves me
> with five individual numbers, and besides it is _way_ too complicated.
> 
> I'm sure this is something I missed in high-school math ... and  I ran
> a check on the archives but didn't find anything.
> 
> Thanks in advance,
> 
> jon
> 

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg              (818) 883-2846
FM Pro Solutions       Los Angeles, California

FileMaker 7 Certified Developer
Associate Member, FileMaker Solutions Alliance
0
Reply Howard 1/11/2005 9:17:46 PM


D'Oh! I _knew_ I was missing something ... in this case brain cells.

For clarification, I want to have the same number of digits in the
field for every record.

Thanks!

Jon

In article <10u8gju6rkhra1@corp.supernews.com>, Howard Schlossberg
<howard@antispahm.fmprosolutions.com> wrote:

> If you always want the final number to have five digits, for example, 
> make the field a text field with auto-enter serial number with the 'next 
> serial number' set to be 00001.  This will increment correctly and will 
> always have five digits.  It must be a text string, as numbers cannot 
> have leading zeroes.

-- 
ls -al: .sig: No such file or directory
0
Reply jon 1/12/2005 3:41:30 PM

You can make a string like this:

If ($Number<10 ; "000" ; If ( $Number<100 ; "00" ; If( $Number<1000 ; "0" ; "" ) ) ) & $Number

Numbers then look like: 0003. 0023, 0234, 2345

--
1
Reply bolla (2) 11/13/2012 9:39:35 PM

2 Replies
1228 Views

(page loaded in 0.069 seconds)

Similiar Articles:













7/24/2012 4:22:49 AM


Reply: