indexing description: "Objects that integer objects for display." project: "Project Goanna " library: "utility" date: "$Date$" revision: "$Revision$" author: "Glenn Maughan " copyright: "Copyright (c) 2001 Glenn Maughan and others" license: "Eiffel Forum Freeware License v1 (see forum.txt)." class INTEGER_FORMATTER -- TODO: this needs VE version feature -- Transformation zero_fill (value, length: INTEGER): STRING is -- Convert 'value' to a string and zero fill to 'length'. -- Truncate right if the result will not fit in 'length'. require positive_length: length > 0 #ifdef ISE local formatter: FORMAT_INTEGER do create formatter.make (length) formatter.zero_fill Result := formatter.formatted (value) ensure zero_filled_integer_exists: Result /= Void correct_length: Result.count = length end end -- class INTEGER_FORMATTER #endif #ifdef SE || VE local pad: STRING do Result := value.out if Result.count < length then -- prepend zeros create pad.make_filled ('0', length - Result.count) Result := pad + Result elseif Result.count > length then -- truncate Result := Result.substring (1, length) end ensure zero_filled_integer_exists: Result /= Void correct_length: Result.count = length end end -- class INTEGER_FORMATTER #endif