HP3000-L Archives

May 1996, 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:
Stan Sieler <[log in to unmask]>
Reply To:
Stan Sieler <[log in to unmask]>
Date:
Wed, 8 May 1996 15:03:13 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (218 lines)
John writes:
 
> According to the AIF:PE documentation, AIF:PE handlers can only
> contain references to routines in NL.PUB.SYS, not XL.PUB.SYS.  Since
> the TurboImage routines all reside in XL.PUB.SYS, it would appear
> that a DBUPDATE handler could not call DBGET to get a "before" image
> of the data set that is being updated.
 
You can probably get around the problem by having your
DBUPDATE handler dynamically load DBGET and call it.
 
Here's some sample code that may help, as it demonstrates the dynamic
loading and the "only try to load it once" concept.  Note: Pascal lacks
the ability to specify the initial value for variables in XL's, unlike
C.  However, it appears that the initial value for all variables in XLs
is 0, unless declared otherwise (as in C).  Thus, the sample code checks
a global variable to see if it is 0, which means "never called before".
 
 
NOTE: you'll need to compile this as a subprogram, not as a program with
an outer block.
 
Note the avoidance of Pascal I/O.
 
 
$standard_level 'os_features'$
$type_coercion 'representation'$
 
program test;
 
type
   dbget_proc_type = Procedure (
           anyvar base        : shortint;
           anyvar dataset     : shortint;
           anyvar mode        : shortint;
           anyvar status      : shortint;
           anyvar list        : shortint;
           anyvar buffer      : shortint;
           anyvar argument    : shortint)
        option uncheckable_anyvar;
 
   fake_plabel_type = record
      xrt         : integer;  {typically like: $40102401}
      linkage     : integer;  {typically like: $00000000}
      end;
 
   pac32          = packed array [1..32] of char;
   str9           = string [9];
   str80          = string [80];
 
var
   altstatus      : integer;
   firstfile      : pac32;
   global_dbget_plabel : dbget_proc_type;
   global_dbget_loaded : integer;   {-1=failed, 0=not yet, else xxx}
   procname       : pac32;
   status         : integer;
 
Function  dascii              : shortint;    intrinsic;
Procedure hperrmsg;                          intrinsic;
Procedure hpgetprocplabel;                   intrinsic;
Procedure print;                             intrinsic;
 
{--------------------------------------------------------------}
function hex32 (n : integer) : str9;
 
   var
      dummy       : shortint;
      s           : str9;
 
   begin
 
$push, range off$
   s := '$00000000';
   dummy := dascii (n, 16, s [2]);
$pop$             {range}
 
   hex32 := s;
 
   end {hex32 proc};
{--------------------------------------------------------------}
function num32 (n : integer) : str9;
 
   var
      len         : shortint;
      s           : str9;
 
   begin
 
$push, range off$
   s := '';
   setstrlen (s, dascii (n, 10, s [1]));
$pop$             {range}
 
   num32 := s;
 
   end {num32 proc};
{**************************************************************}
procedure spout (s : str80);
 
   begin
 
   print (s, - strlen (s), 0);
 
   end {spout proc};
{**************************************************************}
procedure test_me;
 
         {dummy vars, to demonstrate call to dynamically loaded}
         {dbget...}
   var
      argument    : shortint;
      base        : shortint;
      buffer      : shortint;
      dataset     : shortint;
      list        : shortint;
      mode        : shortint;
      istatus     : shortint;
 
   begin
 
   try
      begin
            {If this is the first time in, then we haven't loaded}
            {the DBGET intrinsic yet, and need to do so...       }
 
      if global_dbget_loaded = 0 then
         begin
                  {prevent subsequent attempts at loading...}
 
         global_dbget_loaded := -1;
 
                  {note that we do the above immediately, so any}
                  {internal traps below will not result in later}
                  {loading attempts.                            }
 
         spout ('Plabel is 0...loading dbget...');
 
         spout ('sizeof plabel = ' +
                   num32 (sizeof (global_dbget_plabel)));
 
         procname := '-dbget-';
         firstfile := '-XL.PUB.SYS-';
 
         hpgetprocplabel (procname,
                     global_dbget_plabel,
                     status,
                     firstfile,
                     true);      {case sensitive}
 
         if status <> 0 then
            begin
            spout ('Failed to load dbget, error ' +
                           hex32 (status) + ':');
            hperrmsg (2, 1, , status, , , altstatus);
            end
 
         else
            begin             {it worked...}
 
            global_dbget_loaded := 1;  {loaded successfully!}
 
            spout ('Loaded dbget ok, plabel = ' +
                hex32 (fake_plabel_type (global_dbget_plabel).xrt) +
                ', ' +
                hex32 (fake_plabel_type (global_dbget_plabel).linkage));
            end;
         end;                 {loading dbget the first time}
 
      if global_dbget_loaded = 1 then
         begin                {call dbget...}
         call (global_dbget_plabel,
                  base, dataset, mode, istatus, list, buffer,
                  argument);
 
         if istatus <> 0 then
            spout ('DBGET returned status = ' + num32 (istatus))
         else
            begin
               {...log the before image}
            end;
         end;                 {dbget plabel available}
 
      end
 
   recover
      begin
      status := escapecode;
      spout ('Unexpected error in test_me: ' + hex32 (status));
      hperrmsg (2, 1, , status, , , altstatus);
      end;
 
   end {test_me proc};
{**************************************************************}
 
begin
 
test_me;
 
end.
 
 
Here's a sample output:
 
   :run hpget.pub
 
   Plabel is 0...loading dbget...
   sizeof plabel = 8
   Loaded dbget ok, plabel = $40102421, $00000000
   DBGET returned status = -11
 
(Not surprisingly, my call to DBGET failed since I didn't pass it an
open database.)
 
--
Stan Sieler                                          [log in to unmask]
                                     http://www.allegro.com/sieler.html

ATOM RSS1 RSS2