: : The format I need to store them would be as follows:
: :
: :
: : 0000
: : 0001
: : 0002
: : 0003
: : 0004
: : 0005
: : 0006
: : 0007
: : 0008
: : 0009
: : 0010
: :
: : and so on. So would using the code posted above work for what I am asking to do?
:
: Yeah. You could store them as an integer (or word). This would store them as 0,1,2,3,4,5,6,7,8,9,10,11,..., but then when you want to display them, just add the correct number of zeroes in front. Easiest way is to convert it to a string before displaying it and pre-pad it with zeroes until it's 4 characters long.
:
:
: FUNCTION PadNumber(Number : Word; Digits : Byte) : String;
: VAR
: X : Byte;
: S : String;
: Begin
: Str(Number,S);
: While Length(S) < 4 Do S := '0' + S;
: PadNumber := S;
: End;
:
: Begin
: WriteLn(PadNumber( 0,4)); { Show '0' with four digits }
: WriteLn(PadNumber( 17,4)); { Show '17' with four digits }
: WriteLn(PadNumber(573,4)); { Show '573' with four digits }
: WriteLn(PadNumber( 12,8)); { Show '12' with eight digits }
: End.
:
:
: This will let you do any number up to 65535 and pad up to 254 zeroes in front (a little excessive, but that's how it goes ;)
:
: Phat Nat
:
:
This code only pads to 4 digits. A small correction will remedy that.