HP3000-L Archives

February 2001, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Ken Hirsch <[log in to unmask]>
Reply To:
Ken Hirsch <[log in to unmask]>
Date:
Fri, 9 Feb 2001 10:00:09 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
Some people have asked about prospects for an Image module for Perl.  It
would be fairly easy to write a module which would give raw access to the
Image intrinsics, but I'm not sure how useful it would be.  Anybody who used
it would have to interpret the buffer returned by DBGET by themselves and
format a buffer for DBPUT by themselves.  There's no built-in support in
Perl for zoned-decimals or packed-decimals.  Of course, Image does not keep
any information about implied decimal points either.

Still you could use integers, floating point numbers, and strings fairly
easily.  Is that useful?


My thoughts on an ideal module would be something along these lines:

1. Create a 'base' object on return from DBOPEN.
Something like:
  $orderbase = ImageBase->new("basename", "password", mode);

2. Using some syntax, you can define implied decimal points or even define
new items in reference to Image items in the database:
maybe:
$orderbase->decimal("DOLLAR-AMOUNT", 2);
$orderbase->define("CENTS","DOLLAR-AMOUNT",4,2,"DISPLAY");

3. When you first use a set, you define an object which links it to the base
object (and hence type information).

$orders = ImageSet->new($orderbase);

You could do things like:
  $orders->setlist("@;");   The default, of course.

if ($found = $orders->find("ORDER-NUMB", 12345)) {
  while ($orders->chainfwd()) {
     printf "%5d  %4.2d\n", $orders->field{QTY},
$orders->field{DOLLAR-AMOUNT}
 }
}

The 'base' parameter is unnecessary, since it's already been tied to the
set.  Buffer and list are implict.  Usually mode would be implicit, too.
There would be a dbstatus associated with each set, so it would be implicit,
too.  The methods would return something sensible, like 1/0 for
success/failure, or maybe the number of records found for a dbfind.  It
would probably be best to throw an exception if there's any but the expected
status returns (e.g. end-of-chain).

Occassionally you might need more than one buffer per set.  I haven't
thought too much about that.  You could get a copy of the raw buffer with,
say,
  $orders->buffer
but how you would interpret it I'm not sure.  Maybe
  $orders->interpret($savedbuf)->field{QTY}


Any thoughts?

ATOM RSS1 RSS2