home *** CD-ROM | disk | FTP | other *** search
/ Old Hackers Atari User Group Newsletter / Old_Hackers_Atari_User_Group_Newsletter_OHMJ91B.atr / csysfil.txt < prev    next >
Text File  |  2023-02-26  |  8KB  |  1 lines

  1. ¢¢=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-¢¢ (KNOWLEDGE  IS  NEVER OLD, ITS ALWAYS¢CURRENT.  This  old  article  is worth¢reading. Ye Ol Editor.) ¢¢          SYNFILE+ PAGE¢¢           Data File Specifications¢April 30, 1985¢Copyright 1985 Daniel L. Moore¢REPRINTED from ACE Newsletter¢December, 1987¢¢¢     There are actually four different¢files   that   together  make  up  one¢SynFile+  datafile.   The files can be¢identified  by  their extenders.  They¢are  .TBL,  .CNF, .IDX, and .Dxx.  The¢.TBL  file  contains  a description of¢the  database  form.   The  .CNF  file¢contains  the  number  of  records and¢disks.   The  .IDX file is the current¢index  data.   And, the .Dxx files are¢the actual data files.¢¢THE .TBL FILE¢¢     The .TBL file is actually made up¢of   three   tables  and  two  numeric¢entities.   The  three  tables are the¢Definitions  table, the Name table and¢the Special Data table.  Each table is¢headed by a two byte length entry, and¢then the data bytes.  If the table has¢a  zero length, there is only a length¢entry.¢¢THE DEFINITIONS TABLE¢¢     The  first table, the Definitions¢table,   consists  of  a  sequence  of¢eleven  bytefield  definitions.  There¢is  one  entry  for  each field in the¢database.   The  format  of each entry¢is:¢¢Byte # Use¢  0  screen column position¢  1  screen row position¢  2-3   field  name  offset  and  name¢length¢  4  field type byte¢  5  field data length¢  6  field mask length¢  7    field  special  offset  (low  8¢bits)¢  8  field data offset (low 8 bits)¢  9   field  data offset (high 3 bits)¢field special offset¢     (high 5 bits)¢ 10  field decimal position¢¢     The  first  two bytes simply give¢the  row  and  column  position of the¢start  of  the field name.  The screen¢is  40  columns by 21 lines and 0,0 is¢the upper left hand corner.¢¢     The field name is actually stored¢in  the second data table.  The low 11¢bits  of  this  16  bit  entry are the¢offset  to  the field name in the Name¢table.   The high 5 bits are the field¢name length.¢¢     The  low  four  bits of the field¢type  entry,  identify the field type.¢The  high  bit  of the field type is a¢flag  for  the  justification  of  the¢field.   If  it  is  set, the field is¢right  justified.   There  are  eleven¢field types in SynFile+ and each has a¢number associated with it.  They are:¢¢  ID number Field Type¢   0  ASCII field¢   1  floating point¢   2  cumulative computed¢   3  table look-up¢   4  dollar¢   5  record number¢   6  date¢   7  integer¢   8  counter¢   9  conditional¢  10  computed¢¢     The  field  data  length  is  the¢length  of the data stored in the disk¢record.   For  ASCII fields, it is one¢greater  than  the  field mask length.¢For floating point, cumulative, dollar¢and  computed  fields,  it is 6 bytes.¢For   table  look-up  and  conditional¢fields,  it  is  one  byte.  All other¢fields have a data length of 2 bytes.¢¢     The  field  mask  length  is  the¢length of the mask(underlines) for the¢characters respectively.¢¢     The  special  offset  is  13 bits¢split between byte 7 and 9. Byte 7 has¢the  low  8  bits  of  data,  and  the¢Special Data table has the high 5.  It¢is   used   by  computed,  cumulative,¢conditional  and table look-up fields.¢The   counter  field  also  uses  this¢entry,  but not as a pointer.  Counter¢fields use it as the increment for the¢field.¢¢     The field offset is 11 bits long.¢ The  low 8 bits are stored in byte 8,¢and  the high 3 bits are stored in the¢low  3  bits  of  byte  9. This is the¢offset from the start of the record to¢the   start  of  the  data  from  this¢field.¢¢     The  field  decimal  position  is¢just  that.   It  tells SynFile how to¢display  floating  point numbers.  The¢current  version  of SynFile only uses¢the low 4 bits of this byte.¢¢     The   others   are  reserved  for¢future use.  If the value of this byte¢is  15, the field will be displayed in¢floating  point,  which is - however -¢the  Atari  FP ROM formats the number.¢For  any  other  value,  SynFile  will¢force  the  display of a decimal point¢and  N  digits  to  the  right  of the¢decimal.¢¢THE NAME TABLE¢¢     The  Name  table contains all the¢field   names.   Each  field  name  is¢stored   as  a  text  entry,  with  no¢delimiters   or   separators   between¢entries.   The names may NOT be stored¢in   the  same  order  as  the  fields¢entries  in the Definitions table(this¢may occur if the form is edited in the¢CREATE module of SynFile).¢¢THE SPECIAL DATA TABLE¢¢     The  Special  Data table contains¢all  formulas  and table look-up field¢datas.¢¢FORMULAS¢¢     Formulas       for      computed,¢cumulative, and conditional fields are¢stored   as   a  sequence  of  command¢tokens.   The CREATE module parses the¢user  entered formula, and converts it¢to   a   tokenized  RPN  formula.   As¢retrieved,  all commands use the top 1¢or  2  entries from the stack.  If the¢high  bit  of a token is set, then the¢field  referenced is an integer(16 bit¢data)     field,    a    FLOAT    will¢automatically be executed on the field¢when   the  data  is  retrieved.   The¢command tokens are:¢¢  TOKEN VALUE COMMAND¢   0  +  (add the top two values)¢   1   -  (subtract the top value from¢second value)¢   2  *¢   3  /¢   4  LOG (take the natural LOG of top¢number)¢   5   LOG10  (take  the common log of¢top number)¢   6  EXP¢   7  EXP10¢   8  ABS¢   9  SORT¢  20  numeric constant¢  30   =   (set  true  flag  if  top 2¢entries are equal)¢  31  >¢  32  <¢  33  <>¢  34  >=¢  35  <=¢ 126  current data¢ 127  END (end of formula flag)¢¢     Numeric  constants(20) are stored¢in  6  byte  internal  floating  point¢representations    of    the   number.¢Entries 30 to 35 are used to compare 2¢numbers   on  the  stack  for  use  in¢conditional operations.¢¢     To  interpret  a  computed field,¢use  the  special data offset to set a¢pointer  to the formula.  The retrieve¢tokens  one  byte  at a time until the¢END  token is found.  The value on the¢top  of  the stack at that time is the¢result of the calculation.¢¢TABLE LOOK-UP¢¢     Table  Look-up entries are stored¢in  packed  entries(the  lenght of the¢entries  is equal to the length of the¢longest   entry,   not   to  the  mask¢length).   The  field data for a table¢look-up   field  is  the  table  entry¢number.   The  first byte of a look-up¢table  is the number of entries in the¢table,  and  the  second  byte  is the¢length  of  the  entries in the table.¢Each   entry   is  stored  as  a  text¢string(with  no  length  byte)  and is¢right  justified  in  the  table  with¢underline   characters(ASCII   95)  as¢filler on the left.¢¢CONDITIONALS¢¢     Conditional    entries    are   a¢combination  of  formula  entries  and¢table  look-up  entries.   The special¢offset  for  a  2 entry look-up table.¢Immediately  after  the  look-up table¢data  is  the  formula  data  for  the¢conditional field.¢¢     The  last  thing in the .TBL file¢are  two  numeric entries.  Each entry¢is  16  bits  long(2 bytes, stored low¢byte,  high byte).  The first entry is¢the  field  count, the second entry is¢the total record length in bytes.  The¢record  length is one greater than the¢sum of the field data lengths.¢¢THE .CNF FILE¢¢     The   .CNF  file  contains  eight¢entries.  Each entry is 16 bits long(2¢bytes,  stored  low  byte, high byte).¢The entries are:¢¢  1   The  length  of  the index array¢entries¢  2   the  total  number of records in¢the datafile¢  3   the  number of data disks in the¢datafile¢  4   the  number of active records in¢the datafile¢  5  the current record number¢  6  the number of index fields¢  7   the current value of the counter¢field¢  8               the             sort¢direction(ascending/descending flag)¢¢THE .IDX FILE¢¢     The   length  of  the  .IDX  file¢varies   with   the  total  number  of¢records in the file, and the length of¢the   current   index.    (Both  these¢numbers  are  in  the .CNF file).  The¢first  32  bytes  of the .IDX file are¢the current index field.  There are 16¢two-byte  entries,  the  first byte of¢each  entry  is  the field number, the¢second is the length of the index data¢for  that  index  entry.   Any unusued¢entries have undefined values, usually¢0.¢¢ *************************************¢