> On Fri, Mar 7, 2008 at 12:12 AM, Heady <adrianhead1
...@googlemail.com> wrote:
> > I've written a small, quick and dirty postscript script to generate 40
> > asset labels in a matrix; with the postscriptbarcode generating a
> > barcode in the middle of the label.
> > So far by various means - I've been able to:
> > * generate a label outline and assign it as a form function (not sure
> > of correct name...)
> > * Generate a logo and assign it as a form function
> <...snip...>
> Hi Heady,
> It's nice to see an example use of PostScript forms on this list -
> thanks for including the code.
> If you are willing and happy to do so, would you be prepared to send a
> version of your finished script that is suitable for including in the
> example scripts section of the repository?http://postscriptbarcode.googlecode.com/svn/scripts/
> > However, apart from the Ghostscript errors which I'll try to sort out
> > latter - which are caused by my logo conversion (long story) that only
> > confuses Ghostscript and prolongs the time the printer processes the
> > page. I cannot for the life of me - work out how to display leading
> > zeros in the above number converted to a string.
> In BWIPP I use the following inline mantra whenever I need to do
> something similar to what you need:
> (000000000000) 12 string copy dup NUM 10 12 string cvrs dup length 12
> exch sub exch putinterval
> This is an efficient technique that does not require the use of
> ephemeral variables - obviously you need to replace the string of
> zeros and the instances of "12" with the appropriate level of padding.
> It is easier to understand when written as follows:
> (000000000000) % Define the padding field
> 12 string copy dup % Persist a new working instance of this into
> which we will insert the number
> NUM 10 12 string cvrs % Convert the given NUM into the equivalent
> base 10 string, up to the length of the field width
> dup length % Find the actual length of the string of NUM
> 12 exch sub % Subtract this length from the field width to find the
> required level of padding, the offset
> exch putinterval % Place the string into the working instance of the
> field at this offset position
> It is fairly easy to wrap this into a function, but I'll leave that as
> an exercise for the reader ;-)
> Hope this helps,
> Tez