diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2013-01-27 23:51:56 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2013-01-27 23:51:56 +0000 |
commit | 6ab0c0f5bf14ed9c15370407b9ee7e0b4b089ae1 (patch) | |
tree | 926065cf45450116098db664e3c61dced9e1f21a /ipl/procs/sername.icn | |
download | icon-upstream/9.4.3.tar.gz |
Initial upstream version 9.4.3upstream/9.4.3
Diffstat (limited to 'ipl/procs/sername.icn')
-rw-r--r-- | ipl/procs/sername.icn | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ipl/procs/sername.icn b/ipl/procs/sername.icn new file mode 100644 index 0000000..44ba202 --- /dev/null +++ b/ipl/procs/sername.icn @@ -0,0 +1,63 @@ +############################################################################ +# +# File: sername.icn +# +# Subject: Procedure to produce serialized names +# +# Author: Ralph E. Griswold +# +# Date: June 27, 1997 +# +############################################################################ +# +# This file is in the public domain. +# +############################################################################ +# +# sername(p, s, n, i) produces a series of names of the form +# p<nnn>s. If n is given it determines the number of digits in +# <nnn>. If i is given it resets the sequence to start with i. <nnn> is +# an right-adjusted integer padded with zeros. +# +# Ordinarily, the arguments only are given on the first call. Subsequent +# calls without arguments give the next name. +# +# For example, sername("image", ".gif", 3, 0) produces "image000.gif", +# and subsequently, sername() produces "image001.gif", image002.gif", +# and so on. +# +# The defaults, if sername() is first called without any arguments is +# as for the call sername("file", 3, 0, ""). +# +# If any argument changes on subsequent calls, all non-null arguments are +# reset. +# +############################################################################ + +procedure sername(p, s, n, i) + static prefix, suffix, cols, serial, name, first + + initial { + prefix := "file" + suffix := "" + cols := 3 + serial := 0 + first := serial + } + + # See if anything has changed. + + if not(p === prefix & s === suffix & n === cols & first === i) then { + prefix := \p + suffix := \s + cols := \n + first := serial := \i + } + + name := prefix || right(serial, cols, "0") || suffix + + serial +:= 1 + + return name + +end |