home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol079 / setdef.pli < prev    next >
Encoding:
Text File  |  1984-04-29  |  1.8 KB  |  97 lines

  1. setdef:
  2.     proc;
  3.     %replace
  4.         true  by '1'b,
  5.         false by '0'b,
  6.         key_f by 0,  /* principal key field */
  7.         qty_f by 1,  /* quantity field */
  8.         prc_f by 2,  /* price field */
  9.         unk_f by 3;  /* unknown field */
  10.  
  11.     %include 'attrib.dcl';
  12.  
  13.     dcl
  14.         def   file;
  15.     dcl
  16.         prc_start fixed ext,
  17.         prc_len   fixed ext,
  18.         qty_start fixed ext,
  19.         qty_len   fixed ext,
  20.         sales_tax dec(4,2) ext;
  21.     dcl
  22.         start     fixed,
  23.         finish    fixed,
  24.         last_fin  fixed,
  25.         i         fixed;
  26.  
  27.  
  28.     on undefinedfile(def)
  29.         begin;
  30.         put skip list('Missing or Empty DEF.DAT File');
  31.         stop;
  32.         end;
  33.  
  34.     open file(def) stream;
  35.  
  36.     on error(1)
  37.         begin;
  38.         put list('Invalid Data Item in DEF.DAT, line',
  39.             lineno(def));
  40.         stop;
  41.         end;
  42.  
  43.     on endfile(def)
  44.         go to end_def;
  45.  
  46.     att_cnt = 0;
  47.     get file(def) list(sales_tax);
  48.  
  49.         do while (att_cnt <= max_att);
  50.         i = att_cnt + 1;
  51.         if i > max_att then
  52.             i = 1;
  53.         get file(def) list
  54.         (att_chars(i), att_type(i), att_start(i), att_finish(i));
  55.         att_cnt = att_cnt + 1;
  56.         if att_cnt > max_att then
  57.             do;
  58.             put list('More than ',max_att,
  59.                 'Fields in DEF.DAT');
  60.             stop;
  61.             end;
  62.         end;
  63.     end_def:
  64.     if att_cnt = 0 then
  65.         signal undefinedfile(def);
  66.  
  67.     prc_start = 0;
  68.     qty_start   = 0;
  69.     /* validate fields, check for price and qty fields */
  70.     last_fin = 0;
  71.         do i = 1 to att_cnt;
  72.         start  = att_start(i);
  73.         finish = att_finish(i);
  74.         if start <= last_fin |
  75.            start > finish |
  76.            finish > max_siz then
  77.             signal error(1);
  78.         last_fin = finish;
  79.         if att_type(i) = qty_f then
  80.             do;
  81.             qty_start = start;
  82.             qty_len   = finish - start + 1;
  83.             end;
  84.         if att_type(i) = prc_f then
  85.             do;
  86.             prc_start = start;
  87.             prc_len   = finish - start + 1;
  88.             end;
  89.         end;
  90.     if prc_start = 0 | qty_start = 0 then
  91.         do;
  92.         put skip list('Missing Price or Quantity in DEF.DAT');
  93.         stop;
  94.         end;
  95.  
  96.     end setdef;
  97.