function zformat, in, n, caps=caps, mdi_leading=mdi_leading, string=string
;
fmt = '(z8.8)'
if (keyword_set(caps)) then fmt = strupcase(fmt)
if (n_elements(n) eq 0) then n = 4
;
out = string(in, format=fmt)
if (n ne 8) then out = strmid(out, 8-n, n)
;
if (keyword_set(mdi_leading)) then out = '0x' + out
if (keyword_set(string)) then out = arr2str(out, delim=' ')
return, out
end