DICTFILE.CLS

21 views
Skip to first unread message

Gary

unread,
Aug 16, 2009, 8:00:38 PM8/16/09
to OpenQM-OpenSource
To all;

I have uploaded a new version of "DICTFILE.CLS". Changes to
DICTFILE.CLS:

17 Aug 09 gdw - Added "dictfile.status" private member to store
status of last
i/o operation set to 999999 for errors
specific to dictfile.cls
(query "last.error" to get detail)
15 Aug 09 gdw - Added "openraw" method to open file in raw mode

This class is VERY functional and very close to being sufficient for
my needs!

Enjoy!

GaryW

Diccon

unread,
Aug 17, 2009, 7:50:56 AM8/17/09
to OpenQM-OpenSource
Good man!
-Diccon

Gary

unread,
Aug 21, 2009, 1:38:26 AM8/21/09
to OpenQM-OpenSource
All,

Good news! I implemented full alternate index access in
DICTFILE.CLS. I have uploaded the latest version. Testing so far has
been excellent, but I can't guarantee I've gotten all the bugs out.
Please bang on this code and see if it fails and let me know. OK,
here's a little example of how the code works.

PROGRAM TEST
SHIPPER=OBJECT("DICTFILE.CLS")
IF SHIPPER->OPEN("SHIPPER") ELSE PRINT SHIPPER->LAST.ERROR; STOP
IF SHIPPER->VIA("NAME") ELSE PRINT SHIPPER->LAST.ERROR; STOP
* This sets the access path to the SHIPPER file using NAME as the key
IF SHIPPER->START("AB") ELSE PRINT SHIPPER->LAST.ERROR
* This sets a pointer for the alternate index to where something with
* the NAME "AB" would be.
IF SHIPPER->READ.NEXT() ELSE PRINT SHIPPER->LAST.ERROR
* Reads the record just to the right of the pointer set by the START
IF SHIPPER->READ.NEXT() ELSE PRINT SHIPPER->LAST.ERROR
* Reads the next record to the right
IF SHIPPER->READ.PREV() ELSE PRINT SHIPPER->LAST.ERROR
* Reads the previous record (should be same record as 1st READ.NEXT)
PRINT SHIPPER->NAME, SHIPPER->CITY, SHIPPER->STATE
* Prints the selected fields, properly formatted
VOID SHIPPER->CLOSE
* Closes shipper file
END

That's all there is to it! Somewhere along the line, I'm going to
make all the error codes unique so you can tell just where an error
comes from. BTW, does anyone know how to set the value returned by
STATUS()?

Enjoy!

GaryW

Ashley Chapman

unread,
Aug 21, 2009, 6:36:54 AM8/21/09
to openqm-o...@googlegroups.com
Gary,

Nice work on the class.


> does anyone know how to set the value returned by
> STATUS()?
>

From memory:-

$internal
@system.return.code = 55555 ;* or whatever.


Ashley Chapman

Gary

unread,
Aug 21, 2009, 9:22:23 AM8/21/09
to OpenQM-OpenSource
Ashley,

Thanks! My motives are selfish -- I need that functionality for my
port. After the kafluffle about INDEX.CLS it turned out it only took
me a couple of hours to implement. I also developed a QUEUE.CLS,
STACK.CLS, and LISTITEM.CLS to implement data structures w/ pointers
such as queues, linked lists, and trees. A little more testing and
I'll throw those out there as well.

GaryW

Gary

unread,
Aug 21, 2009, 9:40:00 AM8/21/09
to OpenQM-OpenSource
OK, I need some advice from the group. DICTFILE.CLS sets a status for
when any number of failures in the class. Currently I am setting the
member "dictfile.status" with the DICTFILE.CLS status codes as well as
status codes from system file operations. I've thought about setting
the system return code INSTEAD of dictfile.status, but this would
require the "$internal" compiler directive and compiling in "-
internal" mode. So:

1) Is this a good idea? It makes it harder for a user to compile and
use the class (but it only has to be done once)

2) Are there ramifications that I am not aware of?

3) Is this more (or less) likely to break in the future?

I'm not exactly sure why the "internal" flag and directive are
needed. Is there something critical to the way OpenQM runs, or is
this just a holdover from the commercial version? Input appreciated!

GaryW


On Aug 21, 6:36 am, Ashley Chapman <ash.chap...@gmail.com> wrote:

Ashley Chapman

unread,
Aug 21, 2009, 9:50:18 AM8/21/09
to openqm-o...@googlegroups.com
2009/8/21 Gary <gwal...@gmail.com>:
>
> OK, I need some advice from the group. DICTFILE.CLS sets a status for
> when any number of failures in the class. Currently I am setting the
> member "dictfile.status" with the DICTFILE.CLS status codes as well as
> status codes from system file operations. I've thought about setting
> the system return code INSTEAD of dictfile.status, but this would
> require the "$internal" compiler directive and compiling in "-
> internal" mode. So:
>
> 1) Is this a good idea? It makes it harder for a user to compile and
> use the class (but it only has to be done once)

No, I don't think it is. The status() function is a bit of a pain, as
it gets overwritten by ANY other action that might set it. So the
status of the obect that you retrieve, might be from an entirely
unrelated action.

>
> 2) Are there ramifications that I am not aware of?
>
> 3) Is this more (or less) likely to break in the future?
>
> I'm not exactly sure why the "internal" flag and directive are
> needed. Is there something critical to the way OpenQM runs, or is
> this just a holdover from the commercial version? Input appreciated!

The normal "user mode" compiler protects your from doing things that
might be calssed as dangerous. Things that only a system programmer
should do.

In short you can do it much better. I tend to return an error code
number to allow easy internationalisation, and avoid setting status()
myself.

>
> GaryW
>
>
> On Aug 21, 6:36 am, Ashley Chapman <ash.chap...@gmail.com> wrote:
>> Gary,
>>
>> Nice work on the class.
>>
>> > does anyone know how to set the value returned by
>> > STATUS()?
>>
>> From memory:-
>>
>> $internal
>> @system.return.code = 55555 ;* or whatever.
>>
>> Ashley Chapman
> >
>



--
Ashley Chapman

GaryW

unread,
Aug 24, 2009, 9:45:01 AM8/24/09
to OpenQM-OpenSource
To all:

Just uploaded a new version of DICTFILE.CLS. Some major changes
here. I decided to make it an option whether or not the class sets
the "@system.return.code" by adding a $DEFINE for SET.STATUS and
appropriate $IFDEF statements. If you define SET.STATUS to anything,
the class will attempt to set @system.return.code on exit, making the
result available in "STATUS()". Note that if you define SET.STATUS,
the class MUST be compiled in "internal" mode (qm -internal).

I decided to trigger ABORT from the class if you try to access a
field that is not defined in the dictionary. This will greatly
simplify debugging of programs that use this class as previously the
class just quietly returned null data if you misspelled a field name,
which is dangerous.

A list of the most recent changes is given below:

* 24 Aug 09 gdw - Added abort if record field is undefined, this
will aid debugging for users of this class
* 24 Aug 09 gdw - Added SET.STATUS define to determine whether
program sets @system.return.code or not
* 24 Aug 09 gdw - Tried to set return codes and error messages where
necessary, added subroutines error and noerror
* 23 Aug 09 gdw - Changed logic to default "start" to set current
key as "KEY" if no alternate index name supplied
* 23 Aug 09 gdw - Added prefixes to datanames to indicate raw or
unformatted data to be returned
* "R%" at the beginning of a dataname will return
the data as raw (unconverted AND unformatted)
* "U%" at the beginning of a dataname will return
the data as unformatted
* 22 Aug 09 gdw - Changed "format.mode" logic to simplify querying
and restoring mode

GaryW

On Aug 21, 9:50 am, Ashley Chapman <ash.chap...@gmail.com> wrote:
> 2009/8/21 Gary <gwalb...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages