In most programming languages this (keeping leading zeros with a fixed format, say, four digits) is done with a print statement using a format string. For example, in Euphoria ( http://www.rapideuphoria.com/ ),
*Syntax:* printf(fn, st, x) *Description:* Print x, to file or device fn, using format string st. If x is a sequence, then format specifiers from st are matched with corresponding elements of x. If x is an atom, then normally st will contain just one format specifier and it will be applied to x, however if st contains multiple format specifiers, each one will be applied to the same value x. Thus printf() always takes exactly 3 arguments. Only the length of the last argument, containing the values to be printed, will vary. The basic format specifiers are:
%d - print an atom as a decimal integer %x - print an atom as a hexadecimal integer. Negative numbers are printed in two's complement, so -1 will print as FFFFFFFF %o - print an atom as an octal integer %s - print a sequence as a string of characters, or print an atom as a single character %e - print an atom as a floating-point number with exponential notation %f - print an atom as a floating-point number with a decimal point but no exponent %g - print an atom as a floating-point number using whichever format seems appropriate, given the magnitude of the number %% - print the '%' character itself
Field widths can be added to the basic formats, e.g. %5d, %8.2f, %10.4s. The number before the decimal point is the minimum field width to be used. The number after the decimal point is the precision to be used.
If the field width is negative, e.g. %-5d then the value will be left-justified within the field. Normally it will be right-justified. If the field width starts with a leading 0, e.g. %08d then leading zeros will be supplied to fill up the field. If the field width starts with a '+' e.g. %+7d then a plus sign will be printed for positive values.
But we don't have this in Epidata. So, unless you use a string field (text), you'll lose those leading zeros. My preference is to just generate (or use) a given unique ID and put the other data (region, area, etc.) in separate fields.
Pete Geddes
At the moment, whenever I enter 0003, the zeros are removed and I am left with just 3.
Does anyone know if there is a way to ensure the zeros remain, and to ensure that each variable entered contains 4 digits?