[Info-vax] OpenVMS - DCL - Data entry filtering
Stephen Hoffman
seaohveh at hoffmanlabs.invalid
Fri Mar 27 18:23:22 EDT 2015
On 2015-03-27 21:59:11 +0000, David Froble said:
> So, you want a unique filename. This should work in most cases ....
>
> $ ! Get date in YYYY-MM-DD format
> $
> $ T = f$cvtime(f$time())
> $
> $ ! Now convert to YYYYMMDD format
> $
> $ YY = f$extract(0,4,T)
> $ MM = f$extract(5,2,T)
> $ DD = f$extract(8,2,T)
> $ HH = f$extract(11,2,T)
> $ NN = f$extract(14,2,T)
> $ SS = f$extract(17,2,T)
> $ XX = f$extract(20,2,T)
> $
> $ D = YY + MM + DD + HH + NN + SS + XX
> $
> $ write sys$output D
Shorter version that fetches a unique filename:
$ d = f$unique()
Or a longer version, that more closely matches the output of David's DCL:
$ d = f$edit(f$cvtime(),"COLLAPSE") - "-" - "-" - ":" - ":" - "."
FWIW, time-based uniqueness tends to fall over within clusters, and
around DST change-over. It's usually a Bad Idea. Use a UUID/GUID if
you have access to one, or use your own index.
--
Pure Personal Opinion | HoffmanLabs LLC
More information about the Info-vax
mailing list