[ic] Barcode Tag for creating code128 barcodes
Kevin Walsh
kevin at cursor.biz
Sun Nov 5 17:38:46 EST 2006
Marty Tennison <marty at sediva.com> wrote:
> Here is a tag that creates code128 barcodes. Enjoy.
> =====================================================
>
> UserTag code128 Order label width height border scale font show_text
> font_margin font_align transparent_text top_margin bottom_margin
> left_margin right_margin padding mode
> UserTag code128 Interpolate
> UserTag code128 Routine <<EOR
>
> [snip]
>
Thanks for that. I'll add it to the list on my RTFM website when I get
a moment. I have a couple of minor suggestions for you:
Your various "||=" operators could be just "||". For instance:
$barcode->height($height ||= 40);
could be just:
$barcode->height($height || 40);
Secondly, I'd return early, with an error message, if no $label
parameter has been provided.
Next, I'd use AddAttr and an $opt hashref instead of listing all of
the parameters on the Order line. I'd keep $label in Order and use
the rest as, for instance, $opt->{width}.
Lastly, it'd be better to call chmod() instead of system("chmod").
Presumably you are calling the executable so that you can provide the
facility to specify the mode as a string like "a+rw". I'd just make
the user provide a raw mode, such as 0666, and then pass the $mode as
an open() parameter. You wouldn't want some muppet to get his giggles
by setting the mode to "; rm -r /path/to/ic".
Hopefully you'll take this as constructive feedback, Marty. Thanks
for sharing. I'm sure that lots of people will find your UserTag
useful.
Oh, the $path would be better defaulted to '.', rather than ''.
On second thoughts, a better default would be to use the ImageDir
directive's setting, like this:
$path = $::Variable->{BARCODE_DIR} || $Vend::Cfg->{ImageDir};
--
_/ _/ _/_/_/_/ _/ _/ _/_/_/ _/ _/
_/_/_/ _/_/ _/ _/ _/ _/_/ _/ K e v i n W a l s h
_/ _/ _/ _/ _/ _/ _/ _/_/ kevin at cursor.biz
_/ _/ _/_/_/_/ _/ _/_/_/ _/ _/
More information about the interchange-users
mailing list