FUNCTION get_ext,i,d ; ; Calculates the file extension corresponding to sequence number i. If ; the second parameter (d) is set, allow only d digits in the returned ; value. ; CASE N_PARAMS() OF 1: ndig=2 ; default number of digits 2: ndig=d ; user selects number of digits (right now only d=1 works) ENDCASE istring=STRCOMPRESS(i,/REMOVE_ALL) & islen=STRLEN(istring) ext='' & FOR ix=0,d-1 DO ext=ext+'0' IF islen GT d THEN $ PRINT,STRING(i,d,FORMAT='("get_ext : ",I3," requires more than ",I3," digits.")') $ ELSE STRPUT,ext,istring,d-islen RETURN,ext END