home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / sql / dames.src < prev    next >
Encoding:
Text File  |  1988-05-03  |  602.0 KB  |  13,535 lines

  1. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2. --constants.txt
  3. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4. package CONSTANTS is
  5.  
  6. --************************************************************************
  7. --**                                                                    **
  8. --**                               CONSTANTS                            **
  9. --**                               ~~~~~~~~~                            **
  10. --****   Version: 01                              Date: 25-Mar-85       **
  11. --**     Author: JF Cabadi                                              **
  12. --**     Modifications:                                                 **
  13. --**                                                                    **
  14. --**  HISTORY  ---------------------------------------------------------**
  15. --**                                                                    **
  16. --**                                                                    **
  17. --**====================================================================**
  18. --**                                                                    **
  19. --**  DESCRIPTION                                                       **
  20. --**  ~~~~~~~~~~~                                                       **
  21. --**                                                                    **
  22. --**                                                                    **
  23. --**  It contains  the  declaration  of  constants which are usually    **
  24. --**  limits of the interface (like the  maximum  column  number for a  **
  25. --**  table, or the maximum character string size), and declaration of  **
  26. --**  types  which  are  widely  used in the interface  (like  integer  **
  27. --**  arrays and word arrays).                                          **
  28. --**                                                                    **
  29. --**                                                                    **
  30. --**  LIMITS  ----------------------------------------------------------**
  31. --**  ~~~~~~                                                            **
  32. --**                                                                    **
  33. --**  CONSTRAINTS  -----------------------------------------------------**
  34. --**  ~~~~~~~~~~~                                                       **
  35. --**                                                                    **
  36. --**  BUGS  ------------------------------------------------------------**
  37. --**  ~~~~                                                              **
  38. --**                                                                    **
  39. --************************************************************************
  40.  
  41.  
  42.  
  43.     NAME_LENGTH : constant := 10;
  44. --      NAME_LENGTH defines the maximum useful length for a table name
  45. -- and for a column name.
  46.  
  47.     COL_NO : constant := 75;
  48. -- maximum column number for a table
  49.  
  50.     TABLE_NO : constant := 5;
  51. -- maximum number of simultaneously locked tables
  52.  
  53.     IMAGE_SZ : constant := 40;
  54. -- maximum character length of the images of an enumeration type
  55.  
  56.     MAX_STRING : constant := 100;
  57. -- maximum size (in characters) of a character string type
  58. -- (this is a DAMES feature)
  59.  
  60.     RANGE_SIZE : constant := IMAGE_SZ;
  61. -- This is the maximum width (in characters) of the image of a
  62. -- range constraint as stored in the ADARANGE reserved table.
  63.  
  64.     type INTEGER_ARRAY_TYPE is array (INTEGER range <>) of INTEGER;
  65. -- array of 32 bits integer's; when used, this type is constrained with
  66. -- an index constraint like : (1 .. n)
  67. -- INTEGER_ARRAY_TYPE objects are used to send or receive values to and
  68. -- from the Fortran77 DAMES access subroutines.
  69.  
  70.     type INTEGER16 is new SHORT_INTEGER;
  71. -- 2 power 16 different values
  72.  
  73.     type INTEGER16_ARRAY_TYPE is array (INTEGER range <>) of INTEGER16;
  74. -- array of 16 bits integer's;
  75. -- INTEGER16_ARRAY_TYPE objects are used to manage values of a
  76. -- not-to-be-known type, while 16 bits is the size of the packets to
  77. -- be managed without modifications inside.
  78.  
  79.     subtype TIDD_TYPE is INTEGER_ARRAY_TYPE (1 .. 3);
  80. -- TIDD_TYPE is used by the F77 access subroutines to define the
  81. -- current row.
  82.  
  83. end CONSTANTS;
  84.  
  85. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  86. --llspec.txt
  87. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  88. with CONSTANTS;
  89. use CONSTANTS;
  90.  
  91. package LL_DAMES is
  92.  
  93.  
  94.     X_CANT_ACCESS_DB,
  95.     X_CANT_ACCESS_TABLE,
  96.     X_FULL_TABLE,
  97.     X_INTERNAL_ERROR,
  98.     X_INVALID_COLUMN,           -- These exceptions are raised
  99.     X_INVALID_CRITERION,        -- in the LL_DAMES subprograms
  100.     X_INVALID_VALUE,            -- when errors occur in.
  101.     X_NO_CURRENT_ROW,
  102.     X_NO_MORE_ROWS,
  103.     X_NO_OPEN_DB,
  104.     X_NO_PREVIOUS_FIND,
  105.     X_NO_PREVIOUS_MATCH,
  106.     X_OPEN_DB,
  107.     X_SHARED_MODE_LOCK,
  108.     X_TABLE_NOT_LOCKED,
  109.     X_TOO_SHORT_STRING : exception;
  110.  
  111.     procedure OPEN (DB_NAME : STRING);
  112. --************************************************************************
  113. --**                                                                    **
  114. --**   UNIT NAME :          OPEN                                        **
  115. --**   ~~~~~~~~~~~                                                      **
  116. --** DESCRIPTION--------------------------------------------------------**
  117. --**                                                                    **
  118. --**                                                                    **
  119. --**                                                                    **
  120. --**    OPEN    must be used to open a database to be accessed via the  **
  121. --**  low  level  Ada  interface.                                       **
  122. --**                                                                    **
  123. --** INPUT--------------------------------------------------------------**
  124. --**                                                                    **
  125. --**  DB_NAME is the name of the database to be open.                   **
  126. --**                                                                    **
  127. --** OUTPUT-------------------------------------------------------------**
  128. --**                                                                    **
  129. --**                                                                    **
  130. --** EXCEPTIONS---------------------------------------------------------**
  131. --**                                                                    **
  132. --**      X_CANT_ACCESS_DB  is  raised  if the requested  database  is  **
  133. --**  unknown, or cannot be accessed for any other reason.              **
  134. --**                                                                    **
  135. --**      X_OPEN_DB is raised if there  is  an  already open database.  **
  136. --**                                                                    **
  137. --************************************************************************
  138.  
  139.     procedure DEFINE_TABLE (TABLE_NAME  : STRING;
  140.                             COLUMN_LIST : STRING);
  141. --************************************************************************
  142. --**                                                                    **
  143. --**   UNIT NAME :          DEFINE_TABLE                                **
  144. --**   ~~~~~~~~~~~                                                      **
  145. --** DESCRIPTION--------------------------------------------------------**
  146. --**                                                                    **
  147. --**                                                                    **
  148. --**                                                                    **
  149. --**  The procedure   DEFINE_TABLE allows the Ada programmer to create  **
  150. --**  a table  ( like  using  the  'DEFINE  TABLE' command of the User  **
  151. --**  Language); the difference  between  these  two  ways is that the  **
  152. --**  first  one  allows  a  greater  choice in column types than  the  **
  153. --**  second  one.   When successfully  created,  the  table  is  left  **
  154. --**  unlocked,  and  thus  must be locked like  any other table to be  **
  155. --**  accessed by the creating unit.                                    **
  156. --**                                                                    **
  157. --** INPUT--------------------------------------------------------------**
  158. --**                                                                    **
  159. --**          * TABLE_NAME is the name of the table to be created.      **
  160. --**                                                                    **
  161. --**          * COLUMN_LIST   is  a  string describing the table;  the  **
  162. --**  column descriptors are separated with semi-colons ; each  column  **
  163. --**  descriptor is a string describing the name,  type,  and optional  **
  164. --**  constraint  of  the  column;  the  following form is to be  used  **
  165. --**  (B.N.F. notation) :                                               **
  166. --**    COLUMN_LIST    := <column_descr> {; <column_descr> }            **
  167. --**    <column_descr> := <scalar_descr> | <record_descr>               **
  168. --**    <record_descr> := <name> <scalar_descr> {, <scalar-descr>}      **
  169. --**    <scalar_descr> := <name> [<type>]                               **
  170. --**    <name> is a valid column name                                   **
  171. --**    <type>         := STRING [(1 .. n)] |                           **
  172. --**                      FLOAT  [<constraint>] |                       **
  173. --**                      INTEGER [<constraint>] |                      **
  174. --**                      <enumeration_type_definition> [<constraint>]  **
  175. --**    <constraint>   := RANGE <value> .. <value>                      **
  176. --**    <value> is a litteral the type of which depends on the          **
  177. --**                      associated  type                              **
  178. --**    <enumeration_type_definition> is defined with this name in the  **
  179. --**                      ADA  Reference  Manual ;  it  is  a  list of  **
  180. --**                      enumeration litterals separated by commas and **
  181. --**                      enclosed in parentheses.                      **
  182. --**                                                                    **
  183. --**                                                                    **
  184. --** OUTPUT-------------------------------------------------------------**
  185. --**                                                                    **
  186. --**                                                                    **
  187. --** EXCEPTIONS---------------------------------------------------------**
  188. --**                                                                    **
  189. --**      X_NO_OPEN_DB  is  raised  if  there  is  no  currently  open  **
  190. --**  database.                                                         **
  191. --**                                                                    **
  192. --**      X_INVALID_COLUMN is raised if COLUMN_LIST  is  not  correct.  **
  193. --**                                                                    **
  194. --**      X_CANT_ACCESS_TABLE is raised if the requested table  cannot  **
  195. --**  be created for any reason.                                        **
  196. --**                                                                    **
  197. --************************************************************************
  198.  
  199.     type ACCESS_MODE_TYPE is (SHARED, EXCLUSIVE);
  200.     type LOCK_TYPE is
  201.         record
  202.             TABLE_NAME  : STRING (1 .. NAME_LENGTH);
  203.             ACCESS_MODE : ACCESS_MODE_TYPE;
  204.         end record;
  205.     type LOCK_LIST_TYPE is array (INTEGER range <>) of LOCK_TYPE;
  206.     procedure LOCK     (LOCK_LIST : LOCK_LIST_TYPE);
  207. --************************************************************************
  208. --**                                                                    **
  209. --**   UNIT NAME :          LOCK                                        **
  210. --**   ~~~~~~~~~~~                                                      **
  211. --** DESCRIPTION--------------------------------------------------------**
  212. --**                                                                    **
  213. --**                                                                    **
  214. --**                                                                    **
  215. --**    LOCK        removes  all  previously  set  locks (if any), and  **
  216. --**  then sets those described in the LOCK_LIST list.                  **
  217. --**                                                                    **
  218. --** INPUT--------------------------------------------------------------**
  219. --**                                                                    **
  220. --**  LOCK_LIST  is  an array  of  LOCK_TYPE  records,  each  of  them  **
  221. --**  describing a single lock; the two components of a LOCK_TYPE  are  **
  222. --**  TABLE_NAME,  which  identifies  a  table, and ACCESS_MODE, which  **
  223. --**  describes in which mode (shared or exclusive) the table is to be  **
  224. --**  accessed.                                                         **
  225. --**                                                                    **
  226. --** OUTPUT-------------------------------------------------------------**
  227. --**                                                                    **
  228. --**                                                                    **
  229. --** EXCEPTIONS---------------------------------------------------------**
  230. --**                                                                    **
  231. --**    X_CANT_ACCESS_TABLE if one or several of the given names do not **
  232. --**  exist in currently open database, or if they cannot all be locked.**
  233. --**                                                                    **
  234. --**    X_NO_OPEN_DB   if   no   database   is   currently   open.      **
  235. --**                                                                    **
  236. --************************************************************************
  237.  
  238.     procedure GET_INFORMATION (TABLE_NAME    : STRING;
  239.                                COLUMN_NUMBER : out POSITIVE;
  240.                                COLUMN_LIST   : out STRING   );
  241. --************************************************************************
  242. --**                                                                    **
  243. --**   UNIT NAME :          GET_INFORMATION                             **
  244. --**   ~~~~~~~~~~~                                                      **
  245. --** DESCRIPTION--------------------------------------------------------**
  246. --**                                                                    **
  247. --**                                                                    **
  248. --**                                                                    **
  249. --**    GET_INFORMATION  returns  to  the  user the information  given  **
  250. --**  during the creation of the named table.                           **
  251. --**                                                                    **
  252. --** INPUT--------------------------------------------------------------**
  253. --**                                                                    **
  254. --**  TABLE_NAME is the name of the table the user wants  information   **
  255. --**  about.                                                            **
  256. --**                                                                    **
  257. --** OUTPUT-------------------------------------------------------------**
  258. --**                                                                    **
  259. --**  COLUMN_NUMBER  is  the  number of columns  the  table  contains.  **
  260. --**                                                                    **
  261. --**  COLUMN_LIST is the list of the column definitions of the  table,  **
  262. --**  in   the   same   format   as  the  DEFINE_TABLE  one.            **
  263. --**                                                                    **
  264. --** EXCEPTIONS---------------------------------------------------------**
  265. --**                                                                    **
  266. --**      X_NO_OPEN_DB  is  raised  if  there  is  no  currently  open  **
  267. --**  database.                                                         **
  268. --**                                                                    **
  269. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  270. --**  exist, or exists but is not currently locked.                     **
  271. --**                                                                    **
  272. --**      X_TOO_SHORT_STRING is raised if COLUMN_LIST  is  not  long    **
  273. --**  enough to be assigned the description of the table.               **
  274. --**                                                                    **
  275. --************************************************************************
  276.  
  277.     procedure UNLOCK;
  278. --************************************************************************
  279. --**                                                                    **
  280. --**   UNIT NAME :          UNLOCK                                      **
  281. --**   ~~~~~~~~~~~                                                      **
  282. --** DESCRIPTION--------------------------------------------------------**
  283. --**                                                                    **
  284. --**                                                                    **
  285. --**                                                                    **
  286. --**    UNLOCK        removes all the previously set  locks  (if any);  **
  287. --**  The previously locked tables must be locked again to be accessed  **
  288. --**  again.                                                            **
  289. --**                                                                    **
  290. --** INPUT--------------------------------------------------------------**
  291. --**                                                                    **
  292. --**                                                                    **
  293. --** OUTPUT-------------------------------------------------------------**
  294. --**                                                                    **
  295. --**                                                                    **
  296. --** EXCEPTIONS---------------------------------------------------------**
  297. --**                                                                    **
  298. --**      X_NO_OPEN_DB  is  raised  if  there  is  no  currently  open  **
  299. --**  database.                                                         **
  300. --**                                                                    **
  301. --************************************************************************
  302.  
  303.     procedure CLOSE;
  304. --************************************************************************
  305. --**                                                                    **
  306. --**   UNIT NAME :          CLOSE                                       **
  307. --**   ~~~~~~~~~~~                                                      **
  308. --** DESCRIPTION--------------------------------------------------------**
  309. --**                                                                    **
  310. --**                                                                    **
  311. --**                                                                    **
  312. --**    CLOSE    must be used when no more actions are to be performed  **
  313. --**  on an open database; all locked tables are  first  unlocked, and  **
  314. --**  the database is then closed.                                      **
  315. --**                                                                    **
  316. --** INPUT--------------------------------------------------------------**
  317. --**                                                                    **
  318. --**                                                                    **
  319. --** OUTPUT-------------------------------------------------------------**
  320. --**                                                                    **
  321. --**                                                                    **
  322. --** EXCEPTIONS---------------------------------------------------------**
  323. --**                                                                    **
  324. --**      X_NO_OPEN_DB  is  raised  if  there  is  no  currently  open  **
  325. --**  database.                                                         **
  326. --**                                                                    **
  327. --**                                                                    **
  328. --************************************************************************
  329.  
  330.     type KEY_MATCH_TYPE is (EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL,
  331.                                             GREATER, GREATER_OR_EQUAL);
  332.     generic
  333.         type USER_COLUMN is private;
  334. --      To use this procedure, the user must first instantiate it with
  335. -- the type of the column to be used as key.
  336.     procedure MATCH (TABLE_NAME   : STRING;
  337.                      COLUMN_NAME  : STRING;
  338.                      KEY_MATCH    : KEY_MATCH_TYPE;
  339.                      COLUMN_VALUE : USER_COLUMN);
  340. --************************************************************************
  341. --**                                                                    **
  342. --**   UNIT NAME :          MATCH                                       **
  343. --**   ~~~~~~~~~~~                                                      **
  344. --** DESCRIPTION--------------------------------------------------------**
  345. --**                                                                    **
  346. --**                                                                    **
  347. --**    MATCH is the first procedure to be used to  build  a selection  **
  348. --**  criterion; a selection criterion is a  logical  expression which  **
  349. --**  has the  value  TRUE  or  FALSE  for  each row of a given table,  **
  350. --**  depending  on  the values  of  columns  of  the  candidate  row.  **
  351. --**                                                                    **
  352. --**  This  logical  expression is  composed  of  one  or  more  basic  **
  353. --**  expressions connected  by  OR's and AND's, each  of  these basic  **
  354. --**  expressions being defined  by  a MATCH call for  the  first, and  **
  355. --**  by an OR_MATCH and by an AND_MATCH call for the following,if the  **
  356. --**  selection criterion  is  not  a  single basic expression itself.  **
  357. --**                                                                    **
  358. --**  A basic expression looks like  'COLUMN  match  VALUE', where the  **
  359. --**  column to be used is defined by its name, where 'match' is '=' ,  **
  360. --**  '/=' , '=<' , '>=' , '<' or '>' , and where VALUE is an Ada value,**
  361. --**  the type of which is the same as the type of the associated column**
  362. --**                                                                    **
  363. --**  All the previous call's to   MATCH,   AND_MATCH,   OR_MATCH       **
  364. --**  or   FIND (for the same table) are forgotten.                     **
  365. --**                                                                    **
  366. --** INPUT--------------------------------------------------------------**
  367. --**                                                                    **
  368. --**  TABLE_NAME  is  the  name  of  the table on which the  selection  **
  369. --**  criterion will be applied.                                        **
  370. --**                                                                    **
  371. --**  COLUMN_NAME is the name of the column to be used.                 **
  372. --**                                                                    **
  373. --**  KEY_MATCH is the match to be performed between the column of the  **
  374. --**  candidate row and COLUMN_VALUE.                                   **
  375. --**                                                                    **
  376. --**  COLUMN_VALUE is the value to  be  compared  with the COLUMN_NAME  **
  377. --**  column.                                                           **
  378. --**                                                                    **
  379. --** OUTPUT-------------------------------------------------------------**
  380. --**                                                                    **
  381. --**                                                                    **
  382. --** EXCEPTIONS---------------------------------------------------------**
  383. --**                                                                    **
  384. --**      X_INVALID_VALUE is raised if  COLUMN_VALUE  is  not  correct. **
  385. --**                                                                    **
  386. --**      X_INVALID_COLUMN  is  raised  if   COLUMN_NAME   is  unknown, **
  387. --**  or if it is  a  record  column  instead  of  a  scalar  column,   **
  388. --**  or if its type does not match the USER_COLUMN type.               **
  389. --**                                                                    **
  390. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  391. --**  exist, or exists but is not currently locked.                     **
  392. --**                                                                    **
  393. --**                                                                    **
  394. --************************************************************************
  395.     generic
  396.         type USER_COLUMN is private;
  397. --      To use this procedure, the user must first instantiate it with
  398. -- the type of the column to be used as key.
  399.     procedure OR_MATCH  (TABLE_NAME   : STRING;
  400.                          COLUMN_NAME  : STRING;
  401.                          KEY_MATCH    : KEY_MATCH_TYPE;
  402.                          COLUMN_VALUE : USER_COLUMN);
  403. --************************************************************************
  404. --**                                                                    **
  405. --**   UNIT NAME :          OR_MATCH                                    **
  406. --**   ~~~~~~~~~~~                                                      **
  407. --** DESCRIPTION--------------------------------------------------------**
  408. --**                                                                    **
  409. --**    OR_MATCH is to be used  to  complete  the selection criterion   **
  410. --**  the user started  to  define  using  the   MATCH procedure.       **
  411. --**  A   selection   criterion   is   a   logical   expression  which  **
  412. --**  has the  value  TRUE  or  FALSE  for  each row of a given table,  **
  413. --**  depending  on  the values  of  columns  of  the  candidate  row.  **
  414. --**                                                                    **
  415. --**  This  logical  expression is  composed  of  one  or  more  basic  **
  416. --**  expressions connected with OR's and AND's, each  of  these basic  **
  417. --**  expressions being defined by a   MATCH call for  the  first, and  **
  418. --**  by an OR_MATCH and or an AND_MATCH call for the following,if the  **
  419. --**  selection criterion  is  not  a  single basic expression itself.  **
  420. --**                                                                    **
  421. --**  A basic expression looks like  'COLUMN  match  VALUE', where the  **
  422. --**  column to be used is defined by its name, where 'match' is '=' ,  **
  423. --**  '/=' , '=<' , '>=' , '<' or '>' , and where VALUE is an Ada value,**
  424. --**  the type of which is the same as the type of the associated column**
  425. --**                                                                    **
  426. --**                                                                    **
  427. --** INPUT--------------------------------------------------------------**
  428. --**                                                                    **
  429. --**  TABLE_NAME  is  the  name  of  the table on which the  selection  **
  430. --**  criterion will be applied.                                        **
  431. --**                                                                    **
  432. --**  COLUMN_NAME is the name of the column to be used.                 **
  433. --**                                                                    **
  434. --**  KEY_MATCH is the match to be performed between the column of the  **
  435. --**  candidate row and COLUMN_VALUE.                                   **
  436. --**                                                                    **
  437. --**  COLUMN_VALUE is the value to  be  compared  with the COLUMN_NAME  **
  438. --**  column.                                                           **
  439. --**                                                                    **
  440. --** OUTPUT-------------------------------------------------------------**
  441. --**                                                                    **
  442. --**                                                                    **
  443. --** EXCEPTIONS---------------------------------------------------------**
  444. --**                                                                    **
  445. --**      X_INVALID_VALUE is raised if COLUMN_VALUE is not correct.     **
  446. --**                                                                    **
  447. --**      X_INVALID_COLUMN  is  raised  if   COLUMN_NAME   is  unknown  **
  448. --**  or if it is  a  record  column  instead  of  a  scalar  column,   **
  449. --**  or if its type does not match the USER_COLUMN type.               **
  450. --**                                                                    **
  451. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  452. --**  exist, or exists but is not currently locked.                     **
  453. --**                                                                    **
  454. --**      X_NO_PREVIOUS_MATCH is raised if a previous call to MATCH is  **
  455. --**  missing.                                                          **
  456. --**                                                                    **
  457. --**                                                                    **
  458. --************************************************************************
  459.     generic
  460.         type USER_COLUMN is private;
  461. --      To use this procedure, the user must first instantiate it with
  462. -- the type of the column to be used as key.
  463.     procedure AND_MATCH (TABLE_NAME   : STRING;
  464.                          COLUMN_NAME  : STRING;
  465.                          KEY_MATCH    : KEY_MATCH_TYPE;
  466.                          COLUMN_VALUE : USER_COLUMN);
  467. --************************************************************************
  468. --**                                                                    **
  469. --**   UNIT NAME :          AND_MATCH                                   **
  470. --**   ~~~~~~~~~~~                                                      **
  471. --** DESCRIPTION--------------------------------------------------------**
  472. --**                                                                    **
  473. --**    AND_MATCH is to be used  to  complete  the selection criterion  **
  474. --**  the user started  to  define  using  the   MATCH procedure.       **
  475. --**  A   selection   criterion   is   a   logical   expression  which  **
  476. --**  has the  value  TRUE  or  FALSE  for  each row of a given table,  **
  477. --**  depending  on  the values  of  columns  of  the  candidate  row.  **
  478. --**                                                                    **
  479. --**  This  logical  expression is  composed  of  one  or  more  basic  **
  480. --**  expressions connected with OR's and AND's, each  of  these basic  **
  481. --**  expressions being defined by a   MATCH call for  the  first, and  **
  482. --**  by an OR_MATCH or an AND_MATCH  call for the  following,  if the  **
  483. --**  selection criterion  is  not  a  single basic expression itself.  **
  484. --**                                                                    **
  485. --**  A basic expression looks like  'COLUMN  match  VALUE', where the  **
  486. --**  column to be used is defined by its name, where 'match' is '=' ,  **
  487. --**  '/=' , '=<' , '>=' , '<' or '>' , and where VALUE is an Ada value,**
  488. --**  the type of which is the same as the type of the associated column**
  489. --**                                                                    **
  490. --**                                                                    **
  491. --** INPUT--------------------------------------------------------------**
  492. --**                                                                    **
  493. --**  TABLE_NAME  is  the  name  of  the table on which the  selection  **
  494. --**  criterion will be applied.                                        **
  495. --**                                                                    **
  496. --**  COLUMN_NAME is the name of the column to be used.                 **
  497. --**                                                                    **
  498. --**  KEY_MATCH is the match to be performed between the column of the  **
  499. --**  candidate row and COLUMN_VALUE.                                   **
  500. --**                                                                    **
  501. --**  COLUMN_VALUE is the value to  be  compared  with the COLUMN_NAME  **
  502. --**  column.                                                           **
  503. --**                                                                    **
  504. --** OUTPUT-------------------------------------------------------------**
  505. --**                                                                    **
  506. --**                                                                    **
  507. --** EXCEPTIONS---------------------------------------------------------**
  508. --**                                                                    **
  509. --**      X_INVALID_VALUE is raised if COLUMN_VALUE is not correct.     **
  510. --**                                                                    **
  511. --**      X_INVALID_COLUMN  is  raised  if   COLUMN_NAME   is  unknown  **
  512. --**  or if it is  a  record  column  instead  of  a  scalar  column,   **
  513. --**  or if its type does not match the USER_COLUMN type.               **
  514. --**                                                                    **
  515. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  516. --**  exist, or exists but is not currently locked.                     **
  517. --**                                                                    **
  518. --**      X_NO_PREVIOUS_MATCH is raised if a previous call to MATCH is  **
  519. --**  missing.                                                          **
  520. --**                                                                    **
  521. --**                                                                    **
  522. --************************************************************************
  523.     procedure FIND          (TABLE_NAME      : STRING);
  524. --************************************************************************
  525. --**                                                                    **
  526. --**   UNIT NAME :          FIND                                        **
  527. --**   ~~~~~~~~~~~                                                      **
  528. --** DESCRIPTION--------------------------------------------------------**
  529. --**                                                                    **
  530. --**                                                                    **
  531. --**  To select a particular set of rows of  a  given  table, the user  **
  532. --**  must first build the selection criterion  by  issuing  a call to  **
  533. --**  the    MATCH  procedure,  and then other  calls  to    AND_MATCH  **
  534. --**  and/or   OR_MATCH procedures to complete the  criterion  when it  **
  535. --**  is   not   only   composed  of  a   single   basic   expression.  **
  536. --**                                                                    **
  537. --**  When the criterion has been built,   FIND is then used to select  **
  538. --**  rows, which will then be accessible using the    FIND_NEXT   and  **
  539. --**    FIND_PREVIOUS functions. The current row is left undefined, as  **
  540. --**  the value of the temporary row.                                   **
  541. --**                                                                    **
  542. --**  The criterion is defined as :                                     **
  543. --**                                                                    **
  544. --**            COL1  KEY_MATCH1  VALUE1       where KEY_MATCH's are    **
  545. --**   and/or   COL2  KEY_MATCH2  VALUE2       some of the following :  **
  546. --**   and/or   COL3  KEY_MATCH3  VALUE3        =  /=  <  =<  >  >=     **
  547. --**    ...                                                             **
  548. --**   and/or   COLn  KEY_MATCHn  VALUEn                                **
  549. --**                                                                    **
  550. --**  where COL1, KEY_MATCH1, VALUE1 are arguments of   MATCH, COL2 ..  **
  551. --**  COLn, KEY_MATCH2 .. KEY_MATCHn  and  VALUE2 ..   VALUEn  are  the **
  552. --**  arguments of the n-1 preceding  AND_MATCH's  or  OR_MATCH's.      **
  553. --**                                                                    **
  554. --** INPUT--------------------------------------------------------------**
  555. --**                                                                    **
  556. --**  TABLE_NAME is the name of the table to which the criterion  will  **
  557. --**  be applied.                                                       **
  558. --**                                                                    **
  559. --** OUTPUT-------------------------------------------------------------**
  560. --**                                                                    **
  561. --**                                                                    **
  562. --** EXCEPTIONS---------------------------------------------------------**
  563. --**                                                                    **
  564. --**      X_INVALID_CRITERION  is  raised  if  the  criterion  is  not  **
  565. --**  correct,  for  instance  when  no  MATCH  has  been   previously  **
  566. --**  performed.                                                        **
  567. --**                                                                    **
  568. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  569. --**  exist, or exists but is not currently locked.                     **
  570. --**                                                                    **
  571. --**                                                                    **
  572. --************************************************************************
  573.  
  574.     function FIND_NEXT     (TABLE_NAME   : STRING) return BOOLEAN;
  575. --************************************************************************
  576. --**                                                                    **
  577. --**   UNIT NAME :          FIND_NEXT                                   **
  578. --**   ~~~~~~~~~~~                                                      **
  579. --** DESCRIPTION--------------------------------------------------------**
  580. --**                                                                    **
  581. --**                                                                    **
  582. --**                                                                    **
  583. --**    FIND_NEXT is used to force the current row to become the first  **
  584. --**  selected   one   following   the   old  current  one,  if   any.  **
  585. --**  If the old current one was the last one, FALSE is then returned;  **
  586. --**  TRUE is otherwise returned.                                       **
  587. --**    If there have not been any other call to NEXT or FIND_NEXT since**
  588. --**  the last call to FIND, the first selected row is then chosen to   **
  589. --**  be the current one.                                               **
  590. --**                                                                    **
  591. --** INPUT--------------------------------------------------------------**
  592. --**                                                                    **
  593. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  594. --**                                                                    **
  595. --** OUTPUT-------------------------------------------------------------**
  596. --**                                                                    **
  597. --**                                                                    **
  598. --** EXCEPTIONS---------------------------------------------------------**
  599. --**                                                                    **
  600. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  601. --**  exist, or exists but is not currently locked.                     **
  602. --**                                                                    **
  603. --**      X_NO_MORE_ROWS is raised if  a  previous  call to FIND_NEXT,  **
  604. --**  FIND_PREVIOUS, NEXT or PREVIOUS  has  returned  the value FALSE.  **
  605. --**                                                                    **
  606. --**      X_NO_PREVIOUS_FIND  if  the  FIND  function  has  not  been   **
  607. --**  previously called.                                                **
  608. --**                                                                    **
  609. --************************************************************************
  610.  
  611.     function FIND_PREVIOUS (TABLE_NAME   : STRING) return BOOLEAN;
  612. --************************************************************************
  613. --**                                                                    **
  614. --**   UNIT NAME :          FIND_PREVIOUS                               **
  615. --**   ~~~~~~~~~~~                                                      **
  616. --** DESCRIPTION--------------------------------------------------------**
  617. --**                                                                    **
  618. --**                                                                    **
  619. --**                                                                    **
  620. --**    FIND_PREVIOUS is used to force the current row  to  become the  **
  621. --**  last  selected  one  preceding the  old  current  one,  if  any.  **
  622. --**  If the old current one was the first one, FALSE is then returned; **
  623. --**  TRUE is otherwise returned.                                       **
  624. --**                                                                    **
  625. --** INPUT--------------------------------------------------------------**
  626. --**                                                                    **
  627. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  628. --**                                                                    **
  629. --** OUTPUT-------------------------------------------------------------**
  630. --**                                                                    **
  631. --**                                                                    **
  632. --** EXCEPTIONS---------------------------------------------------------**
  633. --**                                                                    **
  634. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  635. --**  exist, or exists but is not currently locked.                     **
  636. --**                                                                    **
  637. --**      X_NO_MORE_ROWS is raised if  a  previous  call to FIND_NEXT,  **
  638. --**  FIND_PREVIOUS, NEXT or PREVIOUS  has  returned  the value FALSE,  **
  639. --**  or if no NEXT nor FIND_NEXT has been called since the last LOCK   **
  640. --**  or FIND.                                                          **
  641. --**                                                                    **
  642. --**      X_NO_PREVIOUS_FIND is raised if the FIND function has not been**
  643. --**  previously called.                                                **
  644. --**                                                                    **
  645. --************************************************************************
  646.  
  647.     function NEXT          (TABLE_NAME   : STRING) return BOOLEAN;
  648. --************************************************************************
  649. --**                                                                    **
  650. --**   UNIT NAME :          NEXT                                        **
  651. --**   ~~~~~~~~~~~                                                      **
  652. --** DESCRIPTION--------------------------------------------------------**
  653. --**                                                                    **
  654. --**                                                                    **
  655. --**                                                                    **
  656. --**    NEXT is used to force the current row to become the first  one  **
  657. --**  following the old current one, if any.                            **
  658. --**  If the old current one was the last one, FALSE is then returned;  **
  659. --**  TRUE is otherwise returned.                                       **
  660. --**    If there have not been any other call to NEXT since the last call**
  661. --**  to LOCK, the first row of the table  is  then  chosen  to  be the **
  662. --**  current row.                                                      **
  663. --**                                                                    **
  664. --** INPUT--------------------------------------------------------------**
  665. --**                                                                    **
  666. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  667. --**                                                                    **
  668. --** OUTPUT-------------------------------------------------------------**
  669. --**                                                                    **
  670. --**                                                                    **
  671. --** EXCEPTIONS---------------------------------------------------------**
  672. --**                                                                    **
  673. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  674. --**  exist, or exists but is not currently locked.                     **
  675. --**                                                                    **
  676. --**      X_NO_MORE_ROWS is raised if  a  previous  call to FIND_NEXT,  **
  677. --**  FIND_PREVIOUS, NEXT or PREVIOUS  has  returned  the value FALSE.  **
  678. --**                                                                    **
  679. --**                                                                    **
  680. --************************************************************************
  681.  
  682.     function PREVIOUS      (TABLE_NAME   : STRING) return BOOLEAN;
  683. --************************************************************************
  684. --**                                                                    **
  685. --**   UNIT NAME :          PREVIOUS                                    **
  686. --**   ~~~~~~~~~~~                                                      **
  687. --** DESCRIPTION--------------------------------------------------------**
  688. --**                                                                    **
  689. --**                                                                    **
  690. --**                                                                    **
  691. --**    PREVIOUS is used to force the current row to  become  the last  **
  692. --**  preceding the old current one, if any.                            **
  693. --**  If the old current one was the first one, FALSE is then returned; **
  694. --**  TRUE is otherwise returned.                                       **
  695. --**                                                                    **
  696. --** INPUT--------------------------------------------------------------**
  697. --**                                                                    **
  698. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  699. --**                                                                    **
  700. --** OUTPUT-------------------------------------------------------------**
  701. --**                                                                    **
  702. --**                                                                    **
  703. --** EXCEPTIONS---------------------------------------------------------**
  704. --**                                                                    **
  705. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  706. --**  exist, or exists but is not currently locked.                     **
  707. --**                                                                    **
  708. --**      X_NO_MORE_ROWS is raised if  a  previous  call to FIND_NEXT,  **
  709. --**  FIND_PREVIOUS, NEXT or PREVIOUS  has  returned  the value FALSE,  **
  710. --**  or if no NEXT nor FIND_NEXT has been called since the last LOCK   **
  711. --**  or FIND.                                                          **
  712. --**                                                                    **
  713. --**                                                                    **
  714. --**                                                                    **
  715. --************************************************************************
  716.  
  717.     generic
  718.         type USER_COLUMN is private;
  719. --      To use this procedure the user must first instantiate its with
  720. -- the type of the column he wants to process
  721.     procedure GET_COLUMN (TABLE_NAME  : STRING;
  722.                           COLUMN_NAME : STRING;
  723.                           ITEM        : out USER_COLUMN);
  724. --************************************************************************
  725. --**                                                                    **
  726. --**   UNIT NAME :          GET_COLUMN                                  **
  727. --**   ~~~~~~~~~~~                                                      **
  728. --** DESCRIPTION--------------------------------------------------------**
  729. --**                                                                    **
  730. --**                                                                    **
  731. --**                                                                    **
  732. --**  GET_COLUMN is used to read a value of a column of the current row **
  733. --**  of the table identified by TABLE_NAME.                            **
  734. --**                                                                    **
  735. --** INPUT--------------------------------------------------------------**
  736. --**                                                                    **
  737. --**  TABLE_NAME : name of the table to be read.                        **
  738. --**  COLUMN_NAME  :  name  of  the  column  to  be  read;  its   type  **
  739. --**  must be USER_COLUMN.                                              **
  740. --**                                                                    **
  741. --** OUTPUT-------------------------------------------------------------**
  742. --**                                                                    **
  743. --**  ITEM  :  user  variable  where  the  value  is  to  be   copied.  **
  744. --**                                                                    **
  745. --** EXCEPTIONS---------------------------------------------------------**
  746. --**                                                                    **
  747. --**      X_INVALID_VALUE is raised if the value read is not correct.   **
  748. --**                                                                    **
  749. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  750. --**  exist, or exists but is not currently locked.                     **
  751. --**                                                                    **
  752. --**      X_INVALID_COLUMN is raised if the given column name does not  **
  753. --**  identify any existing column of the identified table, or if its   **
  754. --**  type does not match the USER_COLUMN type.                         **
  755. --**                                                                    **
  756. --**      X_NO_CURRENT_ROW is raised if the current  row  is undefined  **
  757. --**  (after  a  LOCK or  a  FIND  has  been  performed,  or  after  a  **
  758. --**  FIND_NEXT, a FIND_PREVIOUS, a NEXT  or  a  PREVIOUS has returned  **
  759. --**  the value FALSE).                                                 **
  760. --**                                                                    **
  761. --**                                                                    **
  762. --**                                                                    **
  763. --************************************************************************
  764.  
  765.     generic
  766.         type USER_ROW is private;
  767. --      To use this procedure the user must first instantiate it with
  768. -- the Ada type corresponding to the row structure. 
  769.     procedure GET_ROW (TABLE_NAME  : STRING;
  770.                        ITEM        : out USER_ROW);     
  771. --************************************************************************
  772. --**                                                                    **
  773. --**   UNIT NAME :          GET_ROW                                     **
  774. --**   ~~~~~~~~~~~                                                      **
  775. --** DESCRIPTION--------------------------------------------------------**
  776. --**                                                                    **
  777. --**                                                                    **
  778. --**                                                                    **
  779. --**   GET_ROW is used  to read the whole current  row  of  the  table  **
  780. --**  identified by TABLE_NAME. The  USER_ROW   type  must  be defined  **
  781. --**  as a record, each component of the record having the same scalar  **
  782. --**  type as the matching column.                                      **
  783. --**                                                                    **
  784. --** INPUT--------------------------------------------------------------**
  785. --**                                                                    **
  786. --**  TABLE_NAME : name of the table to be read.                        **
  787. --**                                                                    **
  788. --** OUTPUT-------------------------------------------------------------**
  789. --**                                                                    **
  790. --**  ITEM  :  user  variable  where  the  value  is  to  be   copied.  **
  791. --**                                                                    **
  792. --** EXCEPTIONS---------------------------------------------------------**
  793. --**                                                                    **
  794. --**      X_INVALID_COLUMN is raised if the USER_ROW type does not match**
  795. --**  the table definition.                                             **
  796. --**                                                                    **
  797. --**      X_INVALID_VALUE is raised if the value read is not correct.   **
  798. --**                                                                    **
  799. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  800. --**  exist, or exists but is not currently locked.                     **
  801. --**                                                                    **
  802. --**      X_NO_CURRENT_ROW is raised if the current  row  is undefined  **
  803. --**  (after  a  LOCK or  a  FIND  has  been  performed,  or  after  a  **
  804. --**  FIND_NEXT, a FIND_PREVIOUS, a NEXT  or  a  PREVIOUS has returned  **
  805. --**  the value FALSE).                                                 **
  806. --**                                                                    **
  807. --**                                                                    **
  808. --************************************************************************
  809.     generic
  810.         type USER_COLUMN is private;
  811. --      To use this procedure the user must first instantiate it with
  812. -- the type of the column to be processed.
  813.     procedure BUILD_COLUMN (TABLE_NAME  : STRING;
  814.                             COLUMN_NAME : STRING;
  815.                             ITEM        : USER_COLUMN);
  816. --************************************************************************
  817. --**                                                                    **
  818. --**   UNIT NAME :          BUILD_COLUMN                                **
  819. --**   ~~~~~~~~~~~                                                      **
  820. --** DESCRIPTION--------------------------------------------------------**
  821. --**                                                                    **
  822. --**                                                                    **
  823. --**                                                                    **
  824. --**    BUILD_COLUMN is used to write a value on a particular column of **
  825. --**  the temporary row of the named table.                             **
  826. --**                                                                    **
  827. --** INPUT--------------------------------------------------------------**
  828. --**                                                                    **
  829. --**  TABLE_NAME : name of the table to be processed.                   **
  830. --**  COLUMN_NAME : name  of  the  column  of  the temporary row to be  **
  831. --**  written; its type must be USER_COLUMN.                            **
  832. --**  ITEM   :   value   to   be  copied  into  the   temporary   row.  **
  833. --**                                                                    **
  834. --** OUTPUT-------------------------------------------------------------**
  835. --**                                                                    **
  836. --**                                                                    **
  837. --** EXCEPTIONS---------------------------------------------------------**
  838. --**                                                                    **
  839. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  840. --**  exist, or exists but is not currently locked.                     **
  841. --**                                                                    **
  842. --**      X_INVALID_COLUMN if the given column name does not identify   **
  843. --**  any existing column of the identified table, or if its type does  **
  844. --**  not match the USER_COLUMN type.                                   **
  845. --**                                                                    **
  846. --**      X_INVALID_VALUE is raised if the  value  does  not match the  **
  847. --**  column definition.                                                **
  848. --**                                                                    **
  849. --**      X_SHARED_MODE_LOCK is raised if the table has been locked in  **
  850. --**  shared   mode;   it   should   have  been  in  exclusive   mode.  **
  851. --**                                                                    **
  852. --************************************************************************
  853.     generic
  854.         type USER_ROW is private;
  855. --      To use this procedure the user must first instantiate it with
  856. -- the Ada type corresponding to the row structure. 
  857.     procedure BUILD_ROW (TABLE_NAME  : STRING;
  858.                          ITEM        : USER_ROW);
  859. --************************************************************************
  860. --**                                                                    **
  861. --**   UNIT NAME :          BUILD_ROW                                   **
  862. --**   ~~~~~~~~~~~                                                      **
  863. --** DESCRIPTION--------------------------------------------------------**
  864. --**                                                                    **
  865. --**                                                                    **
  866. --**                                                                    **
  867. --**   BUILD_ROW is used to update the whole temporary row of a table.  **
  868. --**  The   USER_ROW   type   must  be a record type,  each  component  **
  869. --**  having  the  same  scalar   type    as    the  matching  column.  **
  870. --**                                                                    **
  871. --** INPUT--------------------------------------------------------------**
  872. --**                                                                    **
  873. --**  TABLE_NAME : name of the table to be processed.                   **
  874. --**  ITEM   :   value   to   be  copied  into  the   temporary   row.  **
  875. --**                                                                    **
  876. --** OUTPUT-------------------------------------------------------------**
  877. --**                                                                    **
  878. --**                                                                    **
  879. --** EXCEPTIONS---------------------------------------------------------**
  880. --**                                                                    **
  881. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  882. --**  exist, or exists but is not currently locked.                     **
  883. --**                                                                    **
  884. --**      X_INVALID_COLUMN is raised if the USER_ROW type does not match**
  885. --**  the table definition.                                             **
  886. --**                                                                    **
  887. --**      X_INVALID_VALUE is raised if the given value does not match   **
  888. --**  the table definition.                                             **
  889. --**                                                                    **
  890. --**      X_SHARED_MODE_LOCK is raised if the table has been locked in  **
  891. --**  shared   mode;   it   should   have  been  in  exclusive   mode.  **
  892. --**                                                                    **
  893. --**                                                                    **
  894. --************************************************************************
  895.  
  896.     procedure UPDATE (TABLE_NAME : STRING);
  897. --************************************************************************
  898. --**                                                                    **
  899. --**   UNIT NAME :          UPDATE                                      **
  900. --**   ~~~~~~~~~~~                                                      **
  901. --** DESCRIPTION--------------------------------------------------------**
  902. --**                                                                    **
  903. --**                                                                    **
  904. --**                                                                    **
  905. --**    UPDATE copies the temporary row of  a  table  into its current  **
  906. --**  row.                                                              **
  907. --**                                                                    **
  908. --** INPUT--------------------------------------------------------------**
  909. --**                                                                    **
  910. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  911. --**                                                                    **
  912. --** OUTPUT-------------------------------------------------------------**
  913. --**                                                                    **
  914. --**                                                                    **
  915. --** EXCEPTIONS---------------------------------------------------------**
  916. --**                                                                    **
  917. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  918. --**  exist, or exists but is not currently locked.                     **
  919. --**                                                                    **
  920. --**      X_NO_CURRENT_ROW is raised if the current  row  is undefined  **
  921. --**  (after  a  LOCK or  a  FIND  has  been  performed,  or  after  a  **
  922. --**  FIND_NEXT, a FIND_PREVIOUS, a NEXT  or  a  PREVIOUS has returned  **
  923. --**  the value FALSE).                                                 **
  924. --**                                                                    **
  925. --**      X_SHARED_MODE_LOCK is raised if the table has been locked in  **
  926. --**  shared   mode;   it   should   have  been  in  exclusive   mode.  **
  927. --**                                                                    **
  928. --**                                                                    **
  929. --************************************************************************
  930.  
  931.     procedure INSERT (TABLE_NAME : STRING);
  932. --************************************************************************
  933. --**                                                                    **
  934. --**   UNIT NAME :          INSERT                                      **
  935. --**   ~~~~~~~~~~~                                                      **
  936. --** DESCRIPTION--------------------------------------------------------**
  937. --**                                                                    **
  938. --**    INSERT copies the temporary row of a table into a new row of    **
  939. --**  this table; this new row is appended at the end of the table if   **
  940. --**  the table is not sorted, and is inserted  so  that  the  table    **
  941. --**  remains sorted, if it already was.                                **
  942. --**                                                                    **
  943. --** INPUT--------------------------------------------------------------**
  944. --**                                                                    **
  945. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  946. --**                                                                    **
  947. --** OUTPUT-------------------------------------------------------------**
  948. --**                                                                    **
  949. --**                                                                    **
  950. --** EXCEPTIONS---------------------------------------------------------**
  951. --**                                                                    **
  952. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  953. --**  exist, or exists but is not currently locked.                     **
  954. --**                                                                    **
  955. --**      X_FULL_TABLE  is  raised  if the table  cannot  be  expanded  **
  956. --**  because already full.                                             **
  957. --**                                                                    **
  958. --**      X_SHARED_MODE_LOCK is raised if the table has been locked in  **
  959. --**  shared   mode;   it   should   have  been  in  exclusive   mode.  **
  960. --**                                                                    **
  961. --**                                                                    **
  962. --************************************************************************
  963.  
  964.  
  965.     procedure DELETE (TABLE_NAME : STRING; NO_MORE_ROW : out BOOLEAN);
  966. --************************************************************************
  967. --**                                                                    **
  968. --**   UNIT NAME :          DELETE                                      **
  969. --**   ~~~~~~~~~~~                                                      **
  970. --** DESCRIPTION--------------------------------------------------------**
  971. --**                                                                    **
  972. --**                                                                    **
  973. --**                                                                    **
  974. --**    DELETE removes the current row of a table; if the removed  one  **
  975. --**  was the only row contained in the table, NO_MORE_ROW is returned  **
  976. --**  TRUE, else it is returned FALSE.                                  **
  977. --**                                                                    **
  978. --** INPUT--------------------------------------------------------------**
  979. --**                                                                    **
  980. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  981. --**                                                                    **
  982. --** OUTPUT-------------------------------------------------------------**
  983. --**                                                                    **
  984. --**  NO_MORE_ROW  is  TRUE  if  the table is left  empty,  and  FALSE  **
  985. --**  otherwise.                                                        **
  986. --**                                                                    **
  987. --** EXCEPTIONS---------------------------------------------------------**
  988. --**                                                                    **
  989. --**      X_TABLE_NOT_LOCKED is raised if the requested table does not  **
  990. --**  exist, or exists but is not currently locked.                     **
  991. --**                                                                    **
  992. --**      X_NO_CURRENT_ROW is raised if the current  row  is undefined  **
  993. --**  (after  a  LOCK or  a  FIND  has  been  performed,  or  after  a  **
  994. --**  FIND_NEXT, a FIND_PREVIOUS, a NEXT  or  a  PREVIOUS has returned  **
  995. --**  the value FALSE).                                                 **
  996. --**                                                                    **
  997. --**      X_SHARED_MODE_LOCK is raised if the table has been locked in  **
  998. --**  shared   mode;   it   should   have  been  in  exclusive   mode.  **
  999. --**                                                                    **
  1000. --**                                                                    **
  1001. --************************************************************************
  1002.  
  1003. end LL_DAMES;        
  1004.  
  1005.  
  1006. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1007. --tabdes.txt
  1008. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1009. package body TABLE_DESCRIPTOR is
  1010.  
  1011.     type HOOK;
  1012.     type HOOK_ACCESS is access HOOK;
  1013.     type HOOK is
  1014.         record
  1015.             FREE    : BOOLEAN;
  1016.                 -- when true, means that the hanging node is currently
  1017.                 -- unused, and can then be chosen to be returned by the
  1018.                 -- NEW_NODE function.
  1019.  
  1020.             OTHER   : HOOK_ACCESS;
  1021.                 -- points to another hook.
  1022.  
  1023.             HANGING : NODE_ACCESS;
  1024.                 -- pointer to a node which can be allocated by the
  1025.                 -- NEW_NODE function.
  1026.         end record;
  1027.  
  1028.     HEAD : HOOK_ACCESS;
  1029.         -- this variable points to the first item of a list of hooks;
  1030.         -- the hanging nodes are those who can be allocated by a call
  1031.         -- to NEW_NODE.
  1032.  
  1033.  
  1034.     type CELL;
  1035.     type CELL_ACCESS is access CELL;
  1036.     type CELL is
  1037.         record
  1038.             OTHER  : CELL_ACCESS;
  1039.             OBJECT : CONSTRAINT_ACCESS;
  1040.         end record;
  1041.     HEAD_CELL : CELL_ACCESS;
  1042.     procedure FREE_NODES (TABLE_ID : INTEGER) is
  1043.         CURSOR : HOOK_ACCESS;
  1044.     begin
  1045.         
  1046.             -- first check that no other table than the TABLE_ID one
  1047.             -- currently needs some of the already hanging nodes; if
  1048.             -- there is one (or more), no node should be freed.
  1049.         for I in 1 .. TABLE_NO loop
  1050.             if I /= TABLE_ID and then
  1051.                TABLE (I).TABLE_STATUS.TABLE_IS_LOCKED and then
  1052.                TABLE (I).TABLE_STATUS.FIND_STATUS /= DEAD then
  1053.                  -- the Ith table currently uses hanging nodes; do not
  1054.                  -- free them
  1055.                 return;
  1056.             end if;
  1057.         end loop;
  1058.  
  1059.             -- all hanging nodes can be freed
  1060.         CURSOR := HEAD;
  1061.  
  1062.         while CURSOR /= null loop
  1063.             CURSOR.all.FREE := TRUE;
  1064.             CURSOR := CURSOR.all.OTHER;
  1065.         end loop;
  1066.     end FREE_NODES;
  1067.  
  1068.  
  1069.     function NEW_NODE return NODE_ACCESS is
  1070.         CURSOR : HOOK_ACCESS;
  1071.     begin
  1072.         CURSOR := HEAD;
  1073.  
  1074.             -- look at the currently hanging nodes in order to find
  1075.             -- a free one
  1076.         while CURSOR /= null loop
  1077.             if CURSOR.all.FREE then
  1078.                 return CURSOR.all.HANGING;
  1079.             else
  1080.                 CURSOR := CURSOR.all.OTHER;
  1081.             end if;
  1082.         end loop;
  1083.  
  1084.             -- since no one of the currently hanging nodes is free, a
  1085.             -- new one is to be allocated, inserted at the beginning
  1086.             -- of the currently hanging nodes list, and its address
  1087.             -- then returned
  1088.         HEAD := new HOOK'(FALSE, HEAD, new NODE);
  1089.         return HEAD.all.HANGING;
  1090.     end NEW_NODE;
  1091.     procedure STORE_CONSTRAINT (CONSTRAINT : CONSTRAINT_ACCESS) is
  1092.         CURSOR : CELL_ACCESS;
  1093.     begin
  1094.         CURSOR := HEAD_CELL;
  1095.         while CURSOR /= null and then CURSOR.all.OBJECT /= null loop
  1096.             CURSOR := CURSOR.all.OTHER;
  1097.         end loop;
  1098.         if CURSOR = null then
  1099.             HEAD_CELL := new CELL'(HEAD_CELL, CONSTRAINT);
  1100.         else
  1101.             CURSOR.all.OBJECT := CONSTRAINT;
  1102.         end if;
  1103.     end STORE_CONSTRAINT;
  1104.  
  1105.     function NEW_CONSTRAINT return CONSTRAINT_ACCESS is
  1106.         CURSOR         : CELL_ACCESS;
  1107.         TO_BE_RETURNED : CONSTRAINT_ACCESS;
  1108.     begin
  1109.         CURSOR := HEAD_CELL;
  1110.         while CURSOR /= null and then CURSOR.all.OBJECT = null loop
  1111.             CURSOR := CURSOR.all.OTHER;
  1112.         end loop;
  1113.         if CURSOR = null then
  1114.             TO_BE_RETURNED := new STRING (1 .. 2 * RANGE_SIZE);
  1115.         else
  1116.             TO_BE_RETURNED := CURSOR.all.OBJECT;
  1117.             CURSOR.all.OBJECT := null;
  1118.         end if;
  1119.         return TO_BE_RETURNED;
  1120.     end NEW_CONSTRAINT;
  1121.  
  1122.         
  1123. end TABLE_DESCRIPTOR;
  1124. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1125. --share.txt
  1126. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1127. with CONSTANTS;
  1128.  
  1129. --************************************************************************
  1130. --**                                                                    **
  1131. --**             package           SHARE                                **
  1132. --**                               ~~~~~                                **
  1133. --****   Version: 01                              Date: 25-Mar-85       **
  1134. --**     Author: JF Cabadi                                              **
  1135. --**     Modifications:                                                 **
  1136. --**                                                                    **
  1137. --**  HISTORY  ---------------------------------------------------------**
  1138. --**                                                                    **
  1139. --**                                                                    **
  1140. --**====================================================================**
  1141. --**                                                                    **
  1142. --**  DESCRIPTION                                                       **
  1143. --**  ~~~~~~~~~~~                                                       **
  1144. --**                                                                    **
  1145. --**  The SHARE package is shared between the bodies of the DAMES  and  **
  1146. --**  LL_DAMES packages; it exists because DAMES is permitted to access **
  1147. --**  the tables of a database which  was  opened  by  LL_DAMES  and    **
  1148. --**  vice-versa.                                                       **
  1149. --**                                                                    **
  1150. --**                                                                    **
  1151. --**                                                                    **
  1152. --**  LIMITS  ----------------------------------------------------------**
  1153. --**  ~~~~~~                                                            **
  1154. --**                                                                    **
  1155. --**  CONSTRAINTS  -----------------------------------------------------**
  1156. --**  ~~~~~~~~~~~                                                       **
  1157. --**                                                                    **
  1158. --**  BUGS  ------------------------------------------------------------**
  1159. --**  ~~~~                                                              **
  1160. --**                                                                    **
  1161. --************************************************************************
  1162.  
  1163. package SHARE is
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.     A_DATABASE_IS_OPEN : BOOLEAN := FALSE;
  1170. -- TRUE when a database is open, and FALSE when no database is open.
  1171.  
  1172.     OPEN_DATABASE_NAME : STRING (1 .. CONSTANTS.NAME_LENGTH);
  1173. -- When a database is open, contains the name of this database.
  1174.  
  1175. end SHARE;
  1176. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1177. --statuspec.txt
  1178. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1179. --************************************************************************
  1180. --**                                                                    **
  1181. --**           package             DAMES_STATUS                         **
  1182. --**                               ~~~~~~~~~~~~                         **
  1183. --****   Version: 01                              Date: 25-Mar-85       **
  1184. --**     Author: JF Cabadi                                              **
  1185. --**     Modifications:                                                 **
  1186. --**                                                                    **
  1187. --**  HISTORY  ---------------------------------------------------------**
  1188. --**                                                                    **
  1189. --**                                                                    **
  1190. --**====================================================================**
  1191. --**                                                                    **
  1192. --**  DESCRIPTION                                                       **
  1193. --**  ~~~~~~~~~~~                                                       **
  1194. --**                                                                    **
  1195. --**   The DAMES_STATUS package is used to keep the current status  of  **
  1196. --**   the DAMES interface :                                            **
  1197. --**        - already successfully used and not closed,             **
  1198. --**            or :                                            **
  1199. --**            - not already used or already closed.                   **
  1200. --**                                                                    **
  1201. --**                                                                    **
  1202. --**  LIMITS  ----------------------------------------------------------**
  1203. --**  ~~~~~~                                                            **
  1204. --**                                                                    **
  1205. --**  CONSTRAINTS  -----------------------------------------------------**
  1206. --**  ~~~~~~~~~~~                                                       **
  1207. --**                                                                    **
  1208. --**  BUGS  ------------------------------------------------------------**
  1209. --**  ~~~~                                                              **
  1210. --**                                                                    **
  1211. --************************************************************************
  1212.  
  1213. package DAMES_STATUS is
  1214.  
  1215.  
  1216.     EMBEDDED_INTERFACE_IS_IN_USE : BOOLEAN;
  1217.         -- TRUE if the EXECUTE or OPEN have been already called, and
  1218.         -- FALSE otherwise, or if CLOSE has been called.
  1219.  
  1220. end DAMES_STATUS;
  1221. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1222. --callspec.txt
  1223. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1224. with CONSTANTS;
  1225. use CONSTANTS;
  1226.  
  1227. package F77_CALLABLES is
  1228.  
  1229.         -- add another attribute definition during the creation of a table
  1230.     procedure ADA_ADDATR (RCKEY  : INTEGER;
  1231.                           ATNAM  : STRING;
  1232.                           ATYPE  : INTEGER;
  1233.                           ATLEN  : INTEGER;
  1234.                           DOMNAM : STRING;
  1235.                           RTN    : out INTEGER);
  1236.  
  1237.         -- close database
  1238.     procedure ADA_CLOSDB;
  1239.  
  1240.         -- close relation
  1241.     procedure ADA_CLOSER (DESCR : INTEGER);
  1242.  
  1243.         -- close relations
  1244.     procedure ADA_CLRELS;
  1245.  
  1246.         -- initialize a temporary row
  1247. --  procedure ADA_CREATT (DESCR : INTEGER; RTN : out INTEGER);
  1248.  
  1249.         -- insert the temporary row at current position
  1250.     procedure ADA_DADD   (DESCR  : INTEGER;
  1251.                           KYNAM  : STRING;
  1252.                           KYIDX  : in out INTEGER_ARRAY_TYPE;
  1253.                           KYVAL0 : STRING;
  1254.                           KYTL   : INTEGER;
  1255.                           KYTLEN : INTEGER_ARRAY_TYPE;
  1256.                           KYTYP  : INTEGER_ARRAY_TYPE;
  1257.                           ATNAM  : STRING;
  1258.                           ATIDX  : in out INTEGER_ARRAY_TYPE;
  1259.                           ATTL   : INTEGER;
  1260.                           ATLEN  : INTEGER_ARRAY_TYPE;
  1261.                           ATTYP  : INTEGER_ARRAY_TYPE;
  1262.                           TIDD   : in out TIDD_TYPE;
  1263.                           RTN    : out INTEGER);
  1264.  
  1265.         -- parse a User Language sentence
  1266.     procedure ADA_DAMSG  (INPLIN : STRING;
  1267.                           INPLEN : in out INTEGER;
  1268.                           MAXLEN : INTEGER;
  1269.                           RTN    : out INTEGER);
  1270.  
  1271.         -- delete the current row
  1272.     procedure ADA_DELETT (DESCR : INTEGER;
  1273.                           TIDD  : in out TIDD_TYPE;
  1274.                           RTN   : out INTEGER);
  1275.  
  1276.         -- find the first row matching a particular criterion
  1277.     procedure ADA_DFIND  (DESCR  : INTEGER;
  1278.                           KYM0   : INTEGER;
  1279.                           KYIDX  : INTEGER_ARRAY_TYPE;
  1280.                           KYVAL0 : STRING;
  1281.                           KYTL   : INTEGER;
  1282.                           TIDD   : in out TIDD_TYPE;
  1283.                           IRD    : INTEGER;
  1284.                           RTN    : out INTEGER);
  1285.         -- get information about an open relation
  1286.         -- ATNAM should be 12 * CONSTANTS.COL_NO characters long
  1287.     procedure ADA_DGINFO (DESCR : INTEGER;
  1288.                           ATNAM : in out STRING;
  1289.                           ATTL  : in out INTEGER;
  1290.                           ATIDX, ATLEN, ATTYP : out INTEGER_ARRAY_TYPE;
  1291.                           RTN  : out INTEGER);
  1292.  
  1293.         -- lock several tables
  1294.     procedure ADA_DLOCK (RELIST : STRING;
  1295.                          MODLIS : INTEGER_ARRAY_TYPE;
  1296.                          LENL   : INTEGER;
  1297.                          RTN    : out INTEGER);
  1298.  
  1299.         -- open a database
  1300.     procedure ADA_DOPENDB (DBNAME : STRING;
  1301.                            RTN    : out INTEGER);
  1302.  
  1303.         -- find previous row
  1304.     procedure ADA_DPREV  (DESCR : INTEGER;
  1305.                           TIDD  : in out TIDD_TYPE;
  1306.                           RTN   : out INTEGER);
  1307.  
  1308.         -- unlocks locked tables
  1309.     procedure ADA_DUNLK;
  1310.  
  1311.         -- break the embedded interface link
  1312.     procedure ADA_ENDDM;
  1313.  
  1314.         -- get access information about an open relation
  1315.     procedure ADA_FACSS  (DESCR : INTEGER;
  1316.                           ACSIFO: out INTEGER_ARRAY_TYPE);
  1317.  
  1318.         -- get an attribute value from the temporary row
  1319.     procedure ADA_GETA   (DESCR  : INTEGER;
  1320.                           ATTINX : INTEGER;
  1321.                           VALUE  : out INTEGER_ARRAY_TYPE;
  1322.                           LENR   : out INTEGER;
  1323.                           FTYP   : out INTEGER;
  1324.                           RTN    : out INTEGER);
  1325.  
  1326.         -- find next row
  1327.     procedure ADA_GETT   (DESCR : INTEGER;
  1328.                           TIDD  : in out TIDD_TYPE;
  1329.                           RTN   : out INTEGER);
  1330.  
  1331.         -- get the whole value of the temporary row
  1332.     procedure ADA_GETTB  (DESCR  : INTEGER;
  1333.                           SINK   : out INTEGER_ARRAY_TYPE;
  1334.                           SINKLN : INTEGER);
  1335.  
  1336.         -- append the temporary row at the end of a relation
  1337.     procedure ADA_INSRTT (DESCR : INTEGER;
  1338.                           TIDD  : in out TIDD_TYPE;
  1339.                           RTN   : out INTEGER);
  1340.  
  1341.         -- insert the temporary row at current position 
  1342. --  procedure ADA_INSRT2 (DESCR : INTEGER;
  1343. --                        TIDD  : in out TIDD_TYPE;
  1344. --                        RTN   : out INTEGER);
  1345.         -- initialize the creation of a relation
  1346.     procedure ADA_IRELC  (RELNAM : STRING;
  1347.                           RCKEY  : out INTEGER;
  1348.                           PERM   : INTEGER);
  1349.  
  1350.         -- initialize the parser
  1351.     procedure ADA_LEXINT;
  1352.  
  1353.         -- writes a message on the screen and in the log_file
  1354.     procedure ADA_MSGTTY (MSG    : STRING;
  1355.                           MSGLEN : INTEGER);
  1356.  
  1357.         -- get the number of tuples of an open relation
  1358.     function  ADA_NUMTUP (DESCR  : INTEGER) return INTEGER;
  1359.  
  1360.         -- open a locked relation
  1361.     procedure ADA_OPENR  (RELNAM : STRING;
  1362.                           DESCR  : out INTEGER;
  1363.                           RTN    : out INTEGER);
  1364.  
  1365.         -- execute the User Language command previously parsed
  1366.         -- by DAMSG
  1367.     procedure ADA_PARSLP (RTN    : out INTEGER);
  1368.  
  1369.         -- put a value into an attribute of a temporary row
  1370.     procedure ADA_PUTA   (DESCR  : INTEGER;
  1371.                           ATTINX : INTEGER;
  1372.                           VALUE  : INTEGER_ARRAY_TYPE;
  1373.                           LENGTH : INTEGER;
  1374.                           RTN    : out INTEGER);
  1375.  
  1376.         -- put a value into a whole temporary row
  1377.     procedure ADA_PUTTB  (DESCR  : INTEGER;
  1378.                           SOURCE : INTEGER_ARRAY_TYPE;
  1379.                           TUPLEN : INTEGER);
  1380.  
  1381.         -- release the relation relation lock
  1382.     procedure ADA_RELLK (OPDB : STRING);
  1383.  
  1384.         -- replace the current tuple with the temporary one
  1385.     procedure ADA_REPLAT (DESCR : INTEGER;
  1386.                           TIDD  : in out TIDD_TYPE;
  1387.                           RTN   : out INTEGER);
  1388.  
  1389.         -- initialize the selection of rows
  1390.     procedure ADA_SETGET (DESCR      : INTEGER;
  1391.                           SETYPE     : INTEGER;
  1392.                           ARG3, ARG4 : TIDD_TYPE;
  1393.                           RTN        : out INTEGER);
  1394.  
  1395.         -- set the relation relation lock
  1396.     procedure ADA_SETLK (OPDB : STRING);
  1397.  
  1398.         -- get the index of an attribute of an open relation
  1399.     procedure ADA_SRCHA  (DESCR : INTEGER;
  1400.                           ATNAM : STRING;
  1401.                           ATIDX : out INTEGER);
  1402.  
  1403.         -- initialize the link through embedded interface
  1404.     procedure ADA_STARTDM;
  1405.         -- terminate a relation creation
  1406.     procedure ADA_TRELC  (RCKEY : INTEGER;
  1407.                           HOW   : INTEGER;
  1408.                           NOPGS : INTEGER;
  1409.                           PGSZ  : INTEGER;
  1410.                           RTN   : out INTEGER);
  1411. end F77_CALLABLES;
  1412. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1413. --conspec.txt
  1414. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1415. with LL_DAMES;
  1416. with UTILITIES;
  1417. with SYSTEM;
  1418.  
  1419. package body CONVERSION is
  1420.  
  1421.     TWO_POWER_8  : constant := 256;
  1422.     TWO_POWER_16 : constant := 65_536;
  1423.     TWO_POWER_24 : constant := 16_777_216;
  1424.  
  1425.  
  1426.     ----------------
  1427.     -- F77_STRING --
  1428.     ----------------
  1429.     function F77_STRING (ADA_STRING : STRING) return INTEGER_ARRAY_TYPE is
  1430.  
  1431. -- F77_STRING converts an ADA string variable into a
  1432. -- FORTRAN77 string variable.
  1433. -- 
  1434. -- If ADA_STRING is an ADA string variable the length of
  1435. -- which is n;
  1436. -- the INTEGER_ARRAY_TYPE returned will then be a n / 4
  1437. -- long ADA integer array.
  1438. -- Each 32 bits integer will be the catenation of
  1439. -- four 8 bits integers, which are the POSITION (ADA
  1440. -- meaning) in the ASCII table, of the four corresponding
  1441. -- characters of ADA_STRING.
  1442.  
  1443.         OFFSET         : constant INTEGER := -3;
  1444.         TO_BE_RETURNED : INTEGER_ARRAY_TYPE (1 .. (ADA_STRING'LENGTH + 3) / 4);
  1445.         LAST           : INTEGER := TO_BE_RETURNED'LAST;
  1446.         STRING_COPY    : STRING (1 .. 4 * LAST);
  1447.     begin
  1448.         STRING_COPY := ADA_STRING &
  1449.                        (ADA_STRING'LENGTH + 1 .. 4 * LAST => ASCII.NUL);
  1450.         -- copy ADA_STRING into STRING_COPY, the length of which
  1451.         -- is a multiple of 4
  1452.  
  1453.         for I in 1 .. LAST loop
  1454.             -- convert each four characters into an integer
  1455.  
  1456.             TO_BE_RETURNED (I) :=
  1457.               TWO_POWER_24 * CHARACTER'POS (STRING_COPY (OFFSET + 4 * I)) +
  1458.               TWO_POWER_16 *
  1459.               CHARACTER'POS (STRING_COPY (OFFSET + 4 * I + 1)) +
  1460.               TWO_POWER_8 * CHARACTER'POS (STRING_COPY (OFFSET + 4 * I + 2)) +
  1461.               CHARACTER'POS (STRING_COPY (OFFSET + 4 * I + 3));
  1462.         end loop;
  1463.  
  1464.         return TO_BE_RETURNED;
  1465.     end F77_STRING;
  1466.  
  1467.  
  1468.     ----------------
  1469.     -- ADA_STRING --
  1470.     ----------------
  1471.     function ADA_STRING (F77_STRING          : INTEGER_ARRAY_TYPE;
  1472.                          SKIP_TRAILING_NULLS : BOOLEAN) return STRING is
  1473.  
  1474. -- ADA_STRING converts a FORTRAN77 string variable into
  1475. -- an ADA string variable :
  1476. -- 
  1477. -- The FORTRAN77 string variable is stored in an ADA
  1478. -- 32 bits integer array (which is the F77_STRING
  1479. -- parameter); each of these integers must be interpreted
  1480. -- as the catenation of four 8 bits integers, each of
  1481. -- which being the POSITION (ADA meaning) in the ASCII
  1482. -- table, of a character. The sequence of characters
  1483. -- thus defined defines the converted string.
  1484. -- 
  1485. -- When SKIP_TRAILING_NULLS is set to TRUE, the
  1486. -- returned string length is chosen so that all
  1487. -- trailing null characters (ASCII.NUL) have been
  1488. -- eliminated.
  1489. -- When SKIP_TRAILING_NULLS is set to FALSE, the
  1490. -- returned string length is exactly four times the
  1491. -- number of integers of the F77_STRING array.
  1492.  
  1493.         LAST           : INTEGER := F77_STRING'LENGTH;
  1494.         TO_BE_RETURNED : STRING (1 .. 4 * LAST);
  1495.         STRING_COPY    : INTEGER_ARRAY_TYPE (1 .. LAST);
  1496.         POSITION       : INTEGER;
  1497.     begin
  1498.         STRING_COPY := F77_STRING;
  1499.         -- F77_STRING is copied into STRING_COPY to be modified
  1500.         -- in situ during processing
  1501.  
  1502.         for I in 1 .. LAST loop
  1503.             -- convert each integer into four characters
  1504.  
  1505.             -- compute first character
  1506.             POSITION := STRING_COPY (I) / TWO_POWER_24;
  1507.             if POSITION not in 0 .. 127 then
  1508.                 POSITION := 0;
  1509.             end if;
  1510.             TO_BE_RETURNED (4 * I - 3) := CHARACTER'VAL (POSITION);
  1511.  
  1512.             -- compute second character
  1513.             STRING_COPY (I) := STRING_COPY (I) - POSITION * TWO_POWER_24;
  1514.             POSITION := STRING_COPY (I) / TWO_POWER_16;
  1515.             if POSITION not in 0 .. 127 then
  1516.                 POSITION := 0;
  1517.             end if;
  1518.             TO_BE_RETURNED (4 * I - 2) := CHARACTER'VAL (POSITION);
  1519.  
  1520.             -- compute third character
  1521.             STRING_COPY (I) := STRING_COPY (I) - POSITION * TWO_POWER_16;
  1522.             POSITION := STRING_COPY (I) / TWO_POWER_8;
  1523.             if POSITION not in 0 .. 127 then
  1524.                 POSITION := 0;
  1525.             end if;
  1526.             TO_BE_RETURNED (4 * I - 1) := CHARACTER'VAL (POSITION);
  1527.             -- compute fourth character
  1528.             STRING_COPY (I) := STRING_COPY (I) - POSITION * TWO_POWER_8;
  1529.             if STRING_COPY (I) not in 0 .. 127 then
  1530.                 STRING_COPY (I) := 0;
  1531.             end if;
  1532.             TO_BE_RETURNED (4 * I) := CHARACTER'VAL (STRING_COPY (I));
  1533.         end loop;
  1534.  
  1535.         if SKIP_TRAILING_NULLS then
  1536.             -- return only non-null characters
  1537.  
  1538.             LAST := 4 * LAST;
  1539.  
  1540.             while TO_BE_RETURNED (LAST) = ASCII.NUL loop
  1541.                 LAST := LAST - 1;
  1542.                 exit when LAST = 0;
  1543.             end loop;
  1544.  
  1545.             return TO_BE_RETURNED (1 .. LAST);
  1546.         else
  1547.             -- return all characters, including null ones
  1548.  
  1549.             return TO_BE_RETURNED;
  1550.         end if;
  1551.     end ADA_STRING;
  1552.  
  1553.  
  1554.  
  1555.     --------------
  1556.     -- F77_ENUM --
  1557.     --------------
  1558.     function F77_ENUM (ADA_ENUM   : NATURAL;
  1559.                        ENUM_DESCR : ENUM_ITEM_ACCESS)
  1560.                         return INTEGER_ARRAY_TYPE is
  1561.  
  1562. -- F77_ENUM returns the character string matching the
  1563. -- image of the enumeration item defined by the position
  1564. -- ADA_ENUM in the ENUM_DESCR enumeration type definition.
  1565. -- 
  1566. -- ENUM_DESCR is a pointer to the first component of a
  1567. -- list, each component of which defining an enumeration
  1568. -- item (the image of the item is in a character string
  1569. -- of the component and the value of the item is the
  1570. -- range of the component in the list).
  1571. -- 
  1572. -- The returned string is returned in a FORTRAN77 format
  1573. -- which means an integer array, each integer defining
  1574. -- four characters.
  1575.  
  1576.         CURSOR : ENUM_ITEM_ACCESS;
  1577.         -- CURSOR is a pointer which will be moved through
  1578.         -- the ENUM_DESCR list.
  1579.  
  1580.     begin
  1581.         CURSOR := ENUM_DESCR;
  1582.         -- CURSOR is set to the beginning of the list
  1583.         for I in 1 .. ADA_ENUM loop
  1584.             -- CURSOR is set to the ADA_ENUMth element of the list.
  1585.             CURSOR := CURSOR.all.OTHER;
  1586.             if CURSOR = null then
  1587.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  1588.                 "internal error when evaluating a value supposed to be");
  1589.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  1590.                 "of an enumeration type");
  1591.                 raise LL_DAMES.X_INTERNAL_ERROR;
  1592.             end if;
  1593.         end loop;
  1594.  
  1595.         return F77_STRING (CURSOR.all.ENUM_IMAGE);
  1596.         -- the character string is returned in the FORTRAN77
  1597.         -- format
  1598.  
  1599.     end F77_ENUM;
  1600.  
  1601.  
  1602.     --------------
  1603.     -- ADA_ENUM --
  1604.     --------------
  1605.     function ADA_ENUM (F77_ENUM   : INTEGER_ARRAY_TYPE;
  1606.                        ENUM_DESCR : ENUM_ITEM_ACCESS) return NATURAL is
  1607.  
  1608. -- ADA_ENUM returns the position of an enumeration item
  1609. -- which is defined by giving its image (the F77_ENUM
  1610. -- fortran string), and the definition of the enumeration
  1611. -- type the item belongs to (the ENUM_DESCR list).
  1612.  
  1613.         CURSOR : ENUM_ITEM_ACCESS;
  1614.         -- CURSOR will be moved through the ENUM_DESCR list
  1615.  
  1616.         COUNT, LAST : NATURAL;
  1617.         -- COUNT will be used to count how many times CURSOR
  1618.         -- has been moved one step
  1619.  
  1620.         ENUM_IMAGE_STRING : STRING (1 .. 4 * F77_ENUM'LENGTH);
  1621.         -- ENUM_IMAGE_STRING will be used to store the item image
  1622.         -- in an ADA format, since it is given in a FORTRAN77
  1623.         -- format (F77_ENUM parameter).
  1624.  
  1625.     begin
  1626.         COUNT := 0;
  1627.         CURSOR := ENUM_DESCR;
  1628.         ENUM_IMAGE_STRING := ADA_STRING (F77_ENUM, FALSE);
  1629.         LAST := ENUM_IMAGE_STRING'LAST;
  1630.  
  1631.         -- first compute LAST, which is the last meaningful
  1632.         -- character of the string (actually the last which
  1633.         -- is not equal to ASCII.NUL)
  1634.         while ENUM_IMAGE_STRING (LAST) = ASCII.NUL loop
  1635.             LAST := LAST - 1;
  1636.             if LAST = 0 then
  1637.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  1638.                 "internal error when evaluating a value supposed to be");
  1639.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  1640.                 "of an enumeration type");
  1641.                 raise LL_DAMES.X_INTERNAL_ERROR;
  1642.             end if;
  1643.         end loop;
  1644.         while CURSOR /= null loop
  1645. -- go through the list
  1646.  
  1647.             if CURSOR.all.ENUM_IMAGE (1 .. LAST) =
  1648.                ENUM_IMAGE_STRING (1 .. LAST) then
  1649.                 -- searched image is found
  1650.                 return COUNT;
  1651.             end if;
  1652.  
  1653.             COUNT := COUNT + 1;
  1654.             CURSOR := CURSOR.OTHER;
  1655.         end loop;
  1656.  
  1657.         -- if the loop ends while CURSOR = null, it means
  1658.         -- that the searched image has not been found.
  1659.         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  1660.         "internal error when evaluating a value supposed to be");
  1661.         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  1662.         "of an enumeration type");
  1663.         raise LL_DAMES.X_INTERNAL_ERROR;
  1664.     end ADA_ENUM;
  1665.  
  1666.  
  1667.  
  1668.     function ADA_SIZE (TABLE_ID, COMPONENT_ID : INTEGER) return INTEGER is
  1669.  
  1670.         -- ADA_SIZE returns the size (in 16 bits words) of the Ada type
  1671.         -- associated with the column defined by TABLE_ID and COMPONENT_ID
  1672.  
  1673.     begin
  1674.         case TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_TYPES (COMPONENT_ID) is
  1675.                 
  1676.                 -- INTEGER type
  1677.             when 1 =>  return 2;
  1678.  
  1679.                 -- FLOAT type
  1680.             when 2 =>  return 2;
  1681.  
  1682.                 -- CHARACTER SRING or ENUMERATION type
  1683.             when 5 => 
  1684.                 if TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES
  1685.                       (COMPONENT_ID) = null then
  1686.                         -- CHARACTER STRING type
  1687.                     return 15 +
  1688.                            TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_LENGTH
  1689.                               (COMPONENT_ID);
  1690.                 else
  1691.                         -- ENUMERATION type
  1692.                     return 1;
  1693.                 end if;
  1694.  
  1695.             when others =>
  1696.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  1697.                 "internal error in a type definition evaluation");
  1698.                 raise LL_DAMES.X_INTERNAL_ERROR;
  1699.         end case;
  1700.     end ADA_SIZE;
  1701.     procedure POSITION (TABLE_ID, COMPONENT_ID : INTEGER;
  1702.                         KIND                   : OBJECT_TYPE;
  1703.                         FIRST_WORD, LAST_WORD  : in out INTEGER) is
  1704.  
  1705.                 -- POSITION returns in FIRST_WORD and LAST_WORD the numbers
  1706.                 -- of the first and of the last 16 bits words of the
  1707.                 -- component in the record, where record and component
  1708.                 -- are defined by TABLE_ID, COMPONENT_ID and KIND.
  1709.                 -- The first word of the record is number 1, and the
  1710.                 -- header of the component (if any) is not included
  1711.                 -- between the two returned positions.
  1712.  
  1713.         IC          : INTEGER;
  1714.         RECORD_NAME : STRING (1 .. NAME_LENGTH);
  1715.     begin
  1716.         FIRST_WORD := 1;
  1717.  
  1718.         case KIND is
  1719.           when WHOLE_TABLE =>
  1720.                 --    - the record to be considered is the one matching
  1721.                 --      the whole TABLE_ID table;
  1722.                 --    - the component to be considered is the column
  1723.                 --      number COMPONENT_ID of the table
  1724.  
  1725.             for I in 1 .. COMPONENT_ID - 1 loop
  1726.                 FIRST_WORD := FIRST_WORD + ADA_SIZE (TABLE_ID, I);
  1727.             end loop;
  1728.  
  1729.             LAST_WORD := FIRST_WORD + ADA_SIZE (TABLE_ID, COMPONENT_ID) - 1;
  1730.             if TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_TYPES
  1731.                 (COMPONENT_ID) = 5
  1732.                 and TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES
  1733.                 (COMPONENT_ID) = null then
  1734.                         -- character string component
  1735.  
  1736.                     FIRST_WORD := FIRST_WORD + 15;
  1737.             end if;
  1738.           when RECORD_COLUMN =>
  1739.                 --    - the record to be considered is the one matching
  1740.                 --      the record column to which the COMPONENT_ID scalar
  1741.                 --      column belongs;
  1742.                 --    - the component to be considered is the column
  1743.                 --      number COMPONENT_ID of the table
  1744.  
  1745.             IC := COMPONENT_ID - 1;
  1746.  
  1747.                 -- store in RECORD_NAME the name of the record column
  1748.                 -- to be considered
  1749.             RECORD_NAME := TABLE (TABLE_ID).TABLE_DEFINITION.IN_RECORD
  1750.                               (COMPONENT_ID);
  1751.  
  1752.             while IC /= 0 and then
  1753.         TABLE (TABLE_ID).TABLE_DEFINITION.IN_RECORD (IC) = RECORD_NAME loop
  1754.                         -- loop for each component of the record
  1755.                 FIRST_WORD := FIRST_WORD + ADA_SIZE (TABLE_ID, IC);
  1756.                 IC := IC - 1;
  1757.             end loop;
  1758.             LAST_WORD := FIRST_WORD + ADA_SIZE (TABLE_ID, COMPONENT_ID) - 1;
  1759.             if TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_TYPES
  1760.                 (COMPONENT_ID) = 5
  1761.                 and TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES
  1762.                 (COMPONENT_ID) = null then
  1763.                         -- character string component
  1764.  
  1765.                     FIRST_WORD := FIRST_WORD + 15;
  1766.             end if;
  1767.           when SCALAR_COLUMN =>
  1768.                 --  - The record to be considered is the one matching
  1769.                 --    the single scalar column defined by TABLE_ID and
  1770.                 --    COLUMN_ID;
  1771.                 --    - the component to be considered is the column
  1772.                 --      number COMPONENT_ID of the table
  1773.             LAST_WORD := ADA_SIZE (TABLE_ID, COMPONENT_ID);
  1774.             if LAST_WORD < 3 then
  1775.                         -- INTEGER, FLOAT or ENUMERATION column
  1776.                 FIRST_WORD := 1;
  1777.             else
  1778.                         -- CHARACTER STRING column
  1779.                 FIRST_WORD := 16;
  1780.             end if;
  1781.         end case;
  1782.     end POSITION;
  1783.  
  1784.     -------------------
  1785.     -- ADD_COMPONENT --
  1786.     -------------------
  1787.     procedure ADD_COMPONENT
  1788.                  (ADA_OBJECT             : in out USER_TYPE;
  1789.                   COMPONENT16            : INTEGER16_ARRAY_TYPE;
  1790.                   TABLE_ID, COMPONENT_ID : INTEGER;
  1791.                   KIND                   : OBJECT_TYPE) is
  1792.  
  1793.         -- ADD_COMPONENT copies the INTEGER16 array bit map of an
  1794.         -- ADA object into a particular place of the ADA_OBJECT object.
  1795.         -- Depending on the value of KIND, ADA_OBJECT is a record
  1796.         -- encapsulating all the columns of the TABLE_ID table, or is
  1797.         -- a record corresponding to a record column of the TABLE_ID
  1798.         -- table, or is a scalar Ada object corresponding to a scalar
  1799.         -- column of the TABLE_ID table.
  1800.         -- In each of these cases, COMPONENT_ID defines the scalar column
  1801.         -- corresponding to COMPONENT16.
  1802.  
  1803.         INTERNAL_ADA_OBJECT   : USER_TYPE;
  1804.         FIRST_WORD, LAST_WORD : INTEGER;
  1805.         type INTEGER16_ACCESS_TYPE is access INTEGER16;
  1806.         INTEGER16_ACCESS      : INTEGER16_ACCESS_TYPE;
  1807.  
  1808.         function INTEGER_TO_INTEGER16_ACCESS is new UNCHECKED_CONVERSION
  1809.                 (INTEGER, INTEGER16_ACCESS_TYPE);
  1810.  
  1811.     begin
  1812.         POSITION (TABLE_ID, COMPONENT_ID, KIND, FIRST_WORD, LAST_WORD);
  1813.  
  1814.                 -- The following instructions cannot be used directly
  1815.                 -- on the ADA_OBJECT object, since it is a formal
  1816.                 -- parameter instead of a current object; these two
  1817.                 -- instructions will then be used on another object
  1818.                 -- (called INTERNAL_ADA_OBJECT) which has been declared
  1819.                 -- in order to let these instructions work normally.
  1820.         INTERNAL_ADA_OBJECT := ADA_OBJECT;
  1821.  
  1822.         for I in FIRST_WORD .. LAST_WORD loop
  1823.             INTEGER16_ACCESS := INTEGER_TO_INTEGER16_ACCESS
  1824.                 (INTEGER (INTERNAL_ADA_OBJECT'ADDRESS) + I - 1);
  1825.             INTEGER16_ACCESS.all := COMPONENT16 (I - FIRST_WORD + 1);
  1826.         end loop;
  1827.         ADA_OBJECT := INTERNAL_ADA_OBJECT;
  1828.     end ADD_COMPONENT;
  1829.  
  1830.     -------------------
  1831.     -- GET_COMPONENT --
  1832.     -------------------
  1833.     procedure GET_COMPONENT (ADA_OBJECT             : USER_TYPE;
  1834.                              COMPONENT16            : out INTEGER16_ARRAY_TYPE;
  1835.                              TABLE_ID, COMPONENT_ID : INTEGER;
  1836.                              KIND                   : OBJECT_TYPE) is
  1837.  
  1838.         -- GET_COMPONENT copies an INTEGER16 array bit map of a part
  1839.         -- of the ADA_OBJECT object into COMPONENT16.
  1840.         -- Depending on the value of KIND, ADA_OBJECT is a record
  1841.         -- encapsulating all the columns of the TABLE_ID table, or is
  1842.         -- a record corresponding to a record column of the TABLE_ID
  1843.         -- table, or is a scalar Ada object corresponding to a scalar
  1844.         -- column of the TABLE_ID table.
  1845.         -- In each of these cases, COMPONENT_ID defines the scalar column
  1846.         -- corresponding to COMPONENT16.
  1847.  
  1848.         INTERNAL_ADA_OBJECT   : USER_TYPE;
  1849.         FIRST_WORD, LAST_WORD : INTEGER;
  1850.         type INTEGER16_ACCESS_TYPE is access INTEGER16;
  1851.         INTEGER16_ACCESS      : INTEGER16_ACCESS_TYPE;
  1852.  
  1853.         function INTEGER_TO_INTEGER16_ACCESS is new UNCHECKED_CONVERSION
  1854.                 (INTEGER, INTEGER16_ACCESS_TYPE);
  1855.  
  1856.     begin
  1857.         POSITION (TABLE_ID, COMPONENT_ID, KIND, FIRST_WORD, LAST_WORD);
  1858.  
  1859.                 -- The following instructions cannot be used directly
  1860.                 -- on the ADA_OBJECT object, since it is a formal
  1861.                 -- parameter instead of a current object; these two
  1862.                 -- instructions will then be used on another object
  1863.                 -- (called INTERNAL_ADA_OBJECT) which has been declared
  1864.                 -- in order to let these instructions work normally.
  1865.         INTERNAL_ADA_OBJECT := ADA_OBJECT;
  1866.  
  1867.         for I in FIRST_WORD .. LAST_WORD loop
  1868.             INTEGER16_ACCESS := INTEGER_TO_INTEGER16_ACCESS
  1869.                 (INTEGER (INTERNAL_ADA_OBJECT'ADDRESS) + I - 1);
  1870.             COMPONENT16 (I - FIRST_WORD + 1) := INTEGER16_ACCESS.all;
  1871.         end loop;
  1872.     end GET_COMPONENT;
  1873.  
  1874.  
  1875. end CONVERSION;
  1876. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1877. --utilspec.txt
  1878. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1879.     with TABLE_DESCRIPTOR;
  1880.     use TABLE_DESCRIPTOR;
  1881.  
  1882. --************************************************************************
  1883. --**                                                                    **
  1884. --**            package            UTILITIES                            **
  1885. --**                               ~~~~~~~~~                            **
  1886. --****   Version: 01                              Date: 25-Mar-85       **
  1887. --**     Author: JF Cabadi                                              **
  1888. --**     Modifications:                                                 **
  1889. --**                                                                    **
  1890. --**  HISTORY  ---------------------------------------------------------**
  1891. --**                                                                    **
  1892. --**                                                                    **
  1893. --**====================================================================**
  1894. --**                                                                    **
  1895. --**  DESCRIPTION                                                       **
  1896. --**  ~~~~~~~~~~~                                                       **
  1897. --**                                                                    **
  1898. --**  The UTILITIES package contains functions and procedures that are  **
  1899. --**  widely  used  in  the  interface.   These   subprograms   are  :  **
  1900. --**                                                                    **
  1901. --**  NORMALIZE to standardize the names transmitted to the interface as**
  1902. --**  character string parameters, before using them (for example  for  **
  1903. --**  comparisons).                                                     **
  1904. --**                                                                    **
  1905. --**  BIT_SIZE,  RECORD_BIT_SIZE   and   TABLE_SIZE   to  compute  the  **
  1906. --**   size of the database  tables,  sets  of  columns, or  columns.   **
  1907. --**                                                                    **
  1908. --**  TABLE_ID, SCALAR_COLUMN_ID and COLUMN to search for a  specified  **
  1909. --**  identifier  in the ones currently known to the interface (i.e. in **
  1910. --**  the TABLE_DESCRIPTOR package).                                    **
  1911. --**                                                                    **
  1912. --**  SELECTION_CRITERION_IS_TRUE to compare the value of an object in  **
  1913. --**  the database to another value.                                    **
  1914. --**                                                                    **
  1915. --**  CHECK_VALUE  to  check  that a given  value  is  correct  for  a  **
  1916. --**  particular range constraint.                                      **
  1917. --**                                                                    **
  1918. --**  OUTPUT_MESSAGE to output an error message to  the  user terminal  **
  1919. --**  and to the DAMES logfile.                                         **
  1920. --**                                                                    **
  1921. --**                                                                    **
  1922. --**                                                                    **
  1923. --**  LIMITS  ----------------------------------------------------------**
  1924. --**  ~~~~~~                                                            **
  1925. --**                                                                    **
  1926. --**  CONSTRAINTS  -----------------------------------------------------**
  1927. --**  ~~~~~~~~~~~                                                       **
  1928. --**                                                                    **
  1929. --**  BUGS  ------------------------------------------------------------**
  1930. --**  ~~~~                                                              **
  1931. --**                                                                    **
  1932. --************************************************************************
  1933.     package UTILITIES is
  1934.         function NORMALIZE (NAME : STRING) return STRING;
  1935.         -- Return a NAME_LENGTH characters long character string, which
  1936.         -- is a copy of NAME, but completed with spaces if name is not
  1937.         -- long enough, cut if NAME is too long, without spaces at the
  1938.         -- beginning, and all in uppercase letters.
  1939.  
  1940.         function BIT_SIZE (TABLE_ID  : INTEGER;
  1941.                            COLUMN_ID : INTEGER) return INTEGER;
  1942.         -- Return the size of the scalar column defined by the TABLE_ID
  1943.         -- and COLUMN_ID indexes to the TABLE variable.
  1944.  
  1945.         function RECORD_BIT_SIZE (TABLE_ID  : INTEGER;
  1946.                                   COLUMN_ID : INTEGER;
  1947.                                   IS_RECORD : BOOLEAN) return INTEGER;
  1948.         -- Return the size of the scalar column defined by the TABLE_ID
  1949.         -- and COLUMN_ID indexes to the TABLE variable, if IS_RECORD is
  1950.         -- FALSE; else return the size of the record column which contains
  1951.         -- the scalar column defined by the TABLE_ID and COLUMN_ID indexes.
  1952.  
  1953.         function TABLE_SIZE (TABLE_ID : INTEGER) return INTEGER;
  1954.         -- Return the size of the whole columns set of the table defined
  1955.         -- by the TABLE_ID index to the TABLE variable.
  1956.  
  1957.         function TABLE_ID (TABLE_NAME : STRING) return INTEGER;
  1958.         -- Return the index of the TABLE_NAME table in the TABLE variable
  1959.         -- or raise the X_TABLE_NOT_LOCKED exception if this name is not
  1960.         -- in the locked tables list of TABLE.
  1961.         -- TABLE_NAME needs not to be normalized, since it is in TABLE_ID
  1962.  
  1963.         function SCALAR_COLUMN_ID (TABLE_ID    : INTEGER;
  1964.                                    COLUMN_NAME : STRING) return INTEGER;
  1965.         -- return the index to the TABLE variable of the COLUMN_NAME
  1966.         -- scalar column of the TABLE_ID table, or raise X_INVALID_COLUMN
  1967.         -- if the searched column is not found.
  1968.         -- COLUMN_NAME needs not to be normalized, since it is in the
  1969.         -- COLUMN procedure itself.
  1970.  
  1971.         procedure COLUMN (TABLE_ID    : INTEGER;
  1972.                           COLUMN_NAME : STRING;
  1973.                           COLUMN_ID   : out INTEGER;
  1974.                           IS_RECORD   : out BOOLEAN);
  1975.         -- return in COLUMN_ID the index to the TABLE variable of the
  1976.         -- COLUMN_NAME column if this is a scalar one, or return the index
  1977.         -- of the first component of the COLUMN_NAME column if this is a
  1978.         -- record column; IS_RECORD is set according to the fact the
  1979.         -- found column is a scalar one or a record one.
  1980.         -- X_INVALID_COLUMN is raised if no scalar column, nor record
  1981.         -- column is found with the requested name.
  1982.         -- COLUMN_NAME needs not to be normalized, since it is in the
  1983.         -- COLUMN procedure itself.
  1984.  
  1985.         function SELECTION_CRITERION_IS_TRUE (TABLE_ID : INTEGER;
  1986.                                               CURSOR   : NODE_ACCESS)
  1987.                                                return BOOLEAN;
  1988.         -- When called with CURSOR pointing to the root of the selection
  1989.         -- criterion binary tree of the TABLE_ID table, return TRUE if
  1990.         -- the selection criterion is true for the current row, and FALSE
  1991.         -- if the selection criterion is false for the current row.
  1992.         procedure CHECK_VALUE (CHECKED, TABLE_ID, COLUMN_ID : INTEGER);
  1993.         -- CHECK_VALUE raises the X_INVALID_VALUE exception if CHECKED
  1994.         -- contains a value which is not in the range attached to the
  1995.         -- COLUMN_ID column of the TABLE_ID table.
  1996.         -- If the column is an INTEGER column, CHECKED is then used
  1997.         -- without conversion;
  1998.         -- If the column is a FLOAT column, CHECKED is then converted
  1999.         -- bit by bit to a FLOAT object;
  2000.         -- If the column is of an ENUMERATION type, CHECKED is then
  2001.         -- supposed to be the position (POS attribute) of the item
  2002.         -- in its type.
  2003.  
  2004.         procedure OUTPUT_MESSAGE (MESSAGE : STRING);
  2005.         -- This procedure appends a character string message to the
  2006.         -- current log file; it is used to give to the user additional
  2007.         -- information when an exception is raised.
  2008.  
  2009.     end UTILITIES;
  2010. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2011. --adaspec.txt
  2012. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2013.     package ADA_TABLES is
  2014.  
  2015. --************************************************************************
  2016. --**                                                                    **
  2017. --**                package         ADA_TABLES                          **
  2018. --**                                ~~~~~~~~~~                          **
  2019. --****   Version: 01                              Date: 25-Mar-85       **
  2020. --**     Author: JF Cabadi                                              **
  2021. --**     Modifications:                                                 **
  2022. --**                                                                    **
  2023. --**  HISTORY  ---------------------------------------------------------**
  2024. --**                                                                    **
  2025. --**                                                                    **
  2026. --**====================================================================**
  2027. --**                                                                    **
  2028. --**  DESCRIPTION                                                       **
  2029. --**  ~~~~~~~~~~~                                                       **
  2030. --**      The ADA_TABLES package  contains  procedures  used to access  **
  2031. --**  the three reserved tables of  the  Ada  Interface Manager; these  **
  2032. --**  tables are ignored by the Fortran77  interface  and  by the User  **
  2033. --**  Langage, and are :                                                **
  2034. --**                                                                    **
  2035. --**    - ADARANGE, which contains information about range constraints; **
  2036. --**  each row of this table defines a range constraint for a column.   **
  2037. --**  Its columns are :                                                 **
  2038. --**    TABLENAME : name of a table,                                    **
  2039. --**    COLNAME   : name of a column of this table,                     **
  2040. --**    MINVALUE  : minimum value for the above defined column,         **
  2041. --**    MAXVALUE  : maximum value for the above defined column.         **
  2042. --**                                                                    **
  2043. --**    - ADARECORD, which contains information about record  columns;  **
  2044. --**  each row of this table defines a component of  a  record  column. **
  2045. --**  Its columns are :                                                 **
  2046. --**    TABLENAME  : name of a table,                                   **
  2047. --**    RECORDNAME : name of a record column,                           **
  2048. --**    COMPONENT  : name of a scalar column which is a component of    **
  2049. --**                 the above defined record column.                   **
  2050. --**                                                                    **
  2051. --**    - ADAENUM, which contains information  about  enumeration type  **
  2052. --**  columns; each row of this table contains the position and the     **
  2053. --**  image of a particular item of an  enumeration  type  column; its  **
  2054. --**  columns are :                                                     **
  2055. --**    TABLENAME : name of a table,                                    **
  2056. --**    COLNAME   : name of a column of this table,                     **
  2057. --**    VALUE     : natural number,                                     **
  2058. --**    IMAGE     : character representation of the VALUEth object of   **
  2059. --**                the enumeration type of the above defined column.   **
  2060. --**                                                                    **
  2061. --**  The  procedures  provided  by  the  ADA_TABLES  package   are  :  **
  2062. --**                                                                    **
  2063. --**  LOCK_ADA_TABLES_IN_SHARED_MODE,                                   **
  2064. --**  LOCK_ADA_TABLES_IN_EXCLUSIVE_MODE, OPEN_ADA_TABLE,                **
  2065. --**  RESET_ADA_TABLE, for access initialization,                       **
  2066. --**                                                                    **
  2067. --**  GET_RANGE, GET_RECORD, GET_ENUM, PUT_RANGE, PUT_RECORD,           **
  2068. --**  PUT_ENUM,  for  writing  to  or  reading   from  the  reserved    **
  2069. --**  tables,                                                           **
  2070. --**                                                                    **
  2071. --**  CLOSE_ADA_TABLES,  UNLOCK_ADA_TABLES  for  terminating access to  **
  2072. --**  the reserved tables.                                              **
  2073. --**                                                                    **
  2074. --**                                                                    **
  2075. --**  LIMITS  ----------------------------------------------------------**
  2076. --**  ~~~~~~                                                            **
  2077. --**                                                                    **
  2078. --**  CONSTRAINTS  -----------------------------------------------------**
  2079. --**  ~~~~~~~~~~~                                                       **
  2080. --**                                                                    **
  2081. --**  BUGS  ------------------------------------------------------------**
  2082. --**  ~~~~                                                              **
  2083. --**                                                                    **
  2084. --************************************************************************
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.         procedure LOCK_ADA_TABLES_IN_SHARED_MODE;
  2092.         -- lock (in the DAMES original meaning) the three reserved tables in
  2093.         -- shared mode if they exist, and notify that they exist or not.
  2094.  
  2095.         procedure LOCK_ADA_TABLES_IN_EXCLUSIVE_MODE (USER_TABLE_NAME : STRING);
  2096.         -- if the reserved tables do not already exist, they are then created.
  2097.         -- In each case, they are then locked in exclusive mode, open, and
  2098.         -- ready to accept call's of the following PUT_XXXXX procedures.
  2099.         -- The USER_TABLE_NAME actual argument is recorded to be used by these
  2100.         -- further call's.
  2101.  
  2102.  
  2103.  
  2104.         procedure OPEN_ADA_TABLE (ADA_TABLE_NAME : STRING);
  2105.         -- open the ADA_TABLE_NAME reserved table if the ADA_TABLE_NAME table 
  2106.         -- exists, else does nothing.
  2107.  
  2108.         procedure RESET_ADA_TABLE (USER_TABLE_NAME : STRING);
  2109.         -- preselect in the open table the rows the TABLE_NAME column of which
  2110.         -- has the value 'USER_TABLE_NAME' if the supposed open table exists,
  2111.         -- else does nothing.
  2112.  
  2113.  
  2114.         procedure GET_RANGE (COLNAME            : out STRING;
  2115.                              MINVALUE, MAXVALUE : out STRING;
  2116.                              EOF                : out BOOLEAN);
  2117.         -- if all the rows of the ADARANGE reserved table have been read,
  2118.         -- return TRUE in EOF, else FALSE, read the following row, and
  2119.         -- return in the out parameters the value of the row.
  2120.         -- If the reserved tables do not exist, EOF is always set to TRUE.
  2121.  
  2122.         procedure GET_RECORD (RECORD_NAME, COMPONENT : out STRING;
  2123.                               EOF                    : out BOOLEAN);
  2124.         -- if all the rows of the ADARECORD reserved table have been read,
  2125.         -- return TRUE in EOF, else FALSE, read the following row, and
  2126.         -- return in the out parameters the value of the row.
  2127.         -- If the reserved tables do not exist, EOF is always returned TRUE.
  2128.  
  2129.         procedure GET_ENUM (COLNAME      : out STRING;
  2130.                             VALUE        : out INTEGER;
  2131.                             IMAGE_STRING : out STRING;
  2132.                             EOF          : out BOOLEAN);
  2133.         -- if all the rows of the ADAENUM reserved table have been read,
  2134.         -- return TRUE in EOF, else FALSE, read the following row, and
  2135.         -- return in the out parameters the value of the row.
  2136.         -- If the reserved tables do not exist, EOF is always returned TRUE.
  2137.         procedure PUT_RANGE (COLNAME : STRING; MINVALUE, MAXVALUE : STRING);
  2138.         -- append a new row to the ADARANGE reserved table, this row containing
  2139.         -- the values defined in the parameters.
  2140.  
  2141.         procedure PUT_RECORD (RECORD_NAME, COMPONENT : STRING);
  2142.         -- append a new row to the ADARECORD reserved table, this row
  2143.         -- containing the values defined in the parameters.
  2144.  
  2145.         procedure PUT_ENUM (COLNAME      : STRING;
  2146.                             VALUE        : INTEGER;
  2147.                             IMAGE_STRING : STRING);
  2148.         -- append a new row to the ADAENUM reserved table, this row containing
  2149.         -- the values defined in the parameters.
  2150.  
  2151.  
  2152.  
  2153.  
  2154.         procedure CLOSE_ADA_TABLE;
  2155.         -- close the currently opened reserved table, which has been
  2156.         -- opened by using OPEN_ADA_TABLE.
  2157.  
  2158.         procedure UNLOCK_ADA_TABLES;
  2159.         -- unlock all locked tables.
  2160.  
  2161.     end ADA_TABLES;
  2162. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2163. --parsespec.txt
  2164. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2165. --************************************************************************
  2166. --**                                                                    **
  2167. --**             package           PARSE                                **
  2168. --**                               ~~~~~                                **
  2169. --****   Version: 01                              Date: 25-Mar-85       **
  2170. --**     Author: JF Cabadi                                              **
  2171. --**     Modifications:                                                 **
  2172. --**                                                                    **
  2173. --**  HISTORY  ---------------------------------------------------------**
  2174. --**                                                                    **
  2175. --**                                                                    **
  2176. --**====================================================================**
  2177. --**                                                                    **
  2178. --**  DESCRIPTION                                                       **
  2179. --**  ~~~~~~~~~~~                                                       **
  2180. --**                                                                    **
  2181. --**  The package PARSE  contains  two  procedures : PARSE_FIRST_LEVEL  **
  2182. --**  and  PARSE_SECOND_LEVEL;  both  contain  the same  flow  control  **
  2183. --**  structure, which is a  parser  recognizing  the table definition  **
  2184. --**  language, as defined for the DEFINE_TABLE  low  level procedure.  **
  2185. --**  The difference between these two  procedures  is  that the first  **
  2186. --**  one performs calls to the DAMES kernel itself in order to define  **
  2187. --**  a new table without the  characteristics  specific  to  the  Ada  **
  2188. --**  interface to DAMES, while the second  one  performs calls to the  **
  2189. --**  ADA_TABLES  package   to  store   the   characteristics  which    **
  2190. --**  are exclusive to the Ada interface to DAMES.                      **
  2191. --**                                                                    **
  2192. --**                                                                    **
  2193. --**                                                                    **
  2194. --**  LIMITS  ----------------------------------------------------------**
  2195. --**  ~~~~~~                                                            **
  2196. --**                                                                    **
  2197. --**  CONSTRAINTS  -----------------------------------------------------**
  2198. --**  ~~~~~~~~~~~                                                       **
  2199. --**                                                                    **
  2200. --**  BUGS  ------------------------------------------------------------**
  2201. --**  ~~~~                                                              **
  2202. --**                                                                    **
  2203. --************************************************************************
  2204.  
  2205.  
  2206.     package PARSE is
  2207.         X_SYNTAX_ERROR : exception;
  2208.         -- X_SYNTAX_ERROR is raised in PARSE_FIRST_LEVEL if a syntactic
  2209.         -- error is detected
  2210.  
  2211.         procedure PARSE_FIRST_LEVEL (COLUMN_LIST : STRING; RCKEY : INTEGER);
  2212.         -- PARSE_FIRST_LEVEL is to be used in order to generate the calls
  2213.         -- to F77_CALLABLES.ADA_ADDATR necessary to define each scalar
  2214.         -- column of a table being currently created
  2215.  
  2216.  
  2217.         procedure PARSE_SECOND_LEVEL (COLUMN_LIST : STRING);
  2218.         -- PARSE_SECOND_LEVEL is to be used in order to generate the calls
  2219.         -- to    ADA_TABLES.PUT_RANGE  ,     ADA_TABLES.PUT_ENUM   and
  2220.         -- ADA_TABLES.PUT_RECORD  necessary to define the enumeration types,
  2221.         -- range constraints and record columns of a table being currently
  2222.         -- created
  2223.  
  2224.     end PARSE;
  2225. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2226. --convert.txt
  2227. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2228. with LL_DAMES;
  2229. with UTILITIES;
  2230. with SYSTEM;
  2231.  
  2232. package body CONVERSION is
  2233.  
  2234.     TWO_POWER_8  : constant := 256;
  2235.     TWO_POWER_16 : constant := 65_536;
  2236.     TWO_POWER_24 : constant := 16_777_216;
  2237.  
  2238.  
  2239.     ----------------
  2240.     -- F77_STRING --
  2241.     ----------------
  2242.     function F77_STRING (ADA_STRING : STRING) return INTEGER_ARRAY_TYPE is
  2243.  
  2244. -- F77_STRING converts an ADA string variable into a
  2245. -- FORTRAN77 string variable.
  2246. -- 
  2247. -- If ADA_STRING is an ADA string variable the length of
  2248. -- which is n;
  2249. -- the INTEGER_ARRAY_TYPE returned will then be a n / 4
  2250. -- long ADA integer array.
  2251. -- Each 32 bits integer will be the catenation of
  2252. -- four 8 bits integers, which are the POSITION (ADA
  2253. -- meaning) in the ASCII table, of the four corresponding
  2254. -- characters of ADA_STRING.
  2255.  
  2256.         OFFSET         : constant INTEGER := -3;
  2257.         TO_BE_RETURNED : INTEGER_ARRAY_TYPE (1 .. (ADA_STRING'LENGTH + 3) / 4);
  2258.         LAST           : INTEGER := TO_BE_RETURNED'LAST;
  2259.         STRING_COPY    : STRING (1 .. 4 * LAST);
  2260.     begin
  2261.         STRING_COPY := ADA_STRING &
  2262.                        (ADA_STRING'LENGTH + 1 .. 4 * LAST => ASCII.NUL);
  2263.         -- copy ADA_STRING into STRING_COPY, the length of which
  2264.         -- is a multiple of 4
  2265.  
  2266.         for I in 1 .. LAST loop
  2267.             -- convert each four characters into an integer
  2268.  
  2269.             TO_BE_RETURNED (I) :=
  2270.               TWO_POWER_24 * CHARACTER'POS (STRING_COPY (OFFSET + 4 * I)) +
  2271.               TWO_POWER_16 *
  2272.               CHARACTER'POS (STRING_COPY (OFFSET + 4 * I + 1)) +
  2273.               TWO_POWER_8 * CHARACTER'POS (STRING_COPY (OFFSET + 4 * I + 2)) +
  2274.               CHARACTER'POS (STRING_COPY (OFFSET + 4 * I + 3));
  2275.         end loop;
  2276.  
  2277.         return TO_BE_RETURNED;
  2278.     end F77_STRING;
  2279.  
  2280.  
  2281.     ----------------
  2282.     -- ADA_STRING --
  2283.     ----------------
  2284.     function ADA_STRING (F77_STRING          : INTEGER_ARRAY_TYPE;
  2285.                          SKIP_TRAILING_NULLS : BOOLEAN) return STRING is
  2286.  
  2287. -- ADA_STRING converts a FORTRAN77 string variable into
  2288. -- an ADA string variable :
  2289. -- 
  2290. -- The FORTRAN77 string variable is stored in an ADA
  2291. -- 32 bits integer array (which is the F77_STRING
  2292. -- parameter); each of these integers must be interpreted
  2293. -- as the catenation of four 8 bits integers, each of
  2294. -- which being the POSITION (ADA meaning) in the ASCII
  2295. -- table, of a character. The sequence of characters
  2296. -- thus defined defines the converted string.
  2297. -- 
  2298. -- When SKIP_TRAILING_NULLS is set to TRUE, the
  2299. -- returned string length is chosen so that all
  2300. -- trailing null characters (ASCII.NUL) have been
  2301. -- eliminated.
  2302. -- When SKIP_TRAILING_NULLS is set to FALSE, the
  2303. -- returned string length is exactly four times the
  2304. -- number of integers of the F77_STRING array.
  2305.  
  2306.         LAST           : INTEGER := F77_STRING'LENGTH;
  2307.         TO_BE_RETURNED : STRING (1 .. 4 * LAST);
  2308.         STRING_COPY    : INTEGER_ARRAY_TYPE (1 .. LAST);
  2309.         POSITION       : INTEGER;
  2310.     begin
  2311.         STRING_COPY := F77_STRING;
  2312.         -- F77_STRING is copied into STRING_COPY to be modified
  2313.         -- in situ during processing
  2314.  
  2315.         for I in 1 .. LAST loop
  2316.             -- convert each integer into four characters
  2317.  
  2318.             -- compute first character
  2319.             POSITION := STRING_COPY (I) / TWO_POWER_24;
  2320.             if POSITION not in 0 .. 127 then
  2321.                 POSITION := 0;
  2322.             end if;
  2323.             TO_BE_RETURNED (4 * I - 3) := CHARACTER'VAL (POSITION);
  2324.  
  2325.             -- compute second character
  2326.             STRING_COPY (I) := STRING_COPY (I) - POSITION * TWO_POWER_24;
  2327.             POSITION := STRING_COPY (I) / TWO_POWER_16;
  2328.             if POSITION not in 0 .. 127 then
  2329.                 POSITION := 0;
  2330.             end if;
  2331.             TO_BE_RETURNED (4 * I - 2) := CHARACTER'VAL (POSITION);
  2332.  
  2333.             -- compute third character
  2334.             STRING_COPY (I) := STRING_COPY (I) - POSITION * TWO_POWER_16;
  2335.             POSITION := STRING_COPY (I) / TWO_POWER_8;
  2336.             if POSITION not in 0 .. 127 then
  2337.                 POSITION := 0;
  2338.             end if;
  2339.             TO_BE_RETURNED (4 * I - 1) := CHARACTER'VAL (POSITION);
  2340.             -- compute fourth character
  2341.             STRING_COPY (I) := STRING_COPY (I) - POSITION * TWO_POWER_8;
  2342.             if STRING_COPY (I) not in 0 .. 127 then
  2343.                 STRING_COPY (I) := 0;
  2344.             end if;
  2345.             TO_BE_RETURNED (4 * I) := CHARACTER'VAL (STRING_COPY (I));
  2346.         end loop;
  2347.  
  2348.         if SKIP_TRAILING_NULLS then
  2349.             -- return only non-null characters
  2350.  
  2351.             LAST := 4 * LAST;
  2352.  
  2353.             while TO_BE_RETURNED (LAST) = ASCII.NUL loop
  2354.                 LAST := LAST - 1;
  2355.                 exit when LAST = 0;
  2356.             end loop;
  2357.  
  2358.             return TO_BE_RETURNED (1 .. LAST);
  2359.         else
  2360.             -- return all characters, including null ones
  2361.  
  2362.             return TO_BE_RETURNED;
  2363.         end if;
  2364.     end ADA_STRING;
  2365.  
  2366.  
  2367.  
  2368.     --------------
  2369.     -- F77_ENUM --
  2370.     --------------
  2371.     function F77_ENUM (ADA_ENUM   : NATURAL;
  2372.                        ENUM_DESCR : ENUM_ITEM_ACCESS)
  2373.                         return INTEGER_ARRAY_TYPE is
  2374.  
  2375. -- F77_ENUM returns the character string matching the
  2376. -- image of the enumeration item defined by the position
  2377. -- ADA_ENUM in the ENUM_DESCR enumeration type definition.
  2378. -- 
  2379. -- ENUM_DESCR is a pointer to the first component of a
  2380. -- list, each component of which defining an enumeration
  2381. -- item (the image of the item is in a character string
  2382. -- of the component and the value of the item is the
  2383. -- range of the component in the list).
  2384. -- 
  2385. -- The returned string is returned in a FORTRAN77 format
  2386. -- which means an integer array, each integer defining
  2387. -- four characters.
  2388.  
  2389.         CURSOR : ENUM_ITEM_ACCESS;
  2390.         -- CURSOR is a pointer which will be moved through
  2391.         -- the ENUM_DESCR list.
  2392.  
  2393.     begin
  2394.         CURSOR := ENUM_DESCR;
  2395.         -- CURSOR is set to the beginning of the list
  2396.         for I in 1 .. ADA_ENUM loop
  2397.             -- CURSOR is set to the ADA_ENUMth element of the list.
  2398.             CURSOR := CURSOR.all.OTHER;
  2399.             if CURSOR = null then
  2400.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2401.                 "internal error when evaluating a value supposed to be");
  2402.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2403.                 "of an enumeration type");
  2404.                 raise LL_DAMES.X_INTERNAL_ERROR;
  2405.             end if;
  2406.         end loop;
  2407.  
  2408.         return F77_STRING (CURSOR.all.ENUM_IMAGE);
  2409.         -- the character string is returned in the FORTRAN77
  2410.         -- format
  2411.  
  2412.     end F77_ENUM;
  2413.  
  2414.  
  2415.     --------------
  2416.     -- ADA_ENUM --
  2417.     --------------
  2418.     function ADA_ENUM (F77_ENUM   : INTEGER_ARRAY_TYPE;
  2419.                        ENUM_DESCR : ENUM_ITEM_ACCESS) return NATURAL is
  2420.  
  2421. -- ADA_ENUM returns the position of an enumeration item
  2422. -- which is defined by giving its image (the F77_ENUM
  2423. -- fortran string), and the definition of the enumeration
  2424. -- type the item belongs to (the ENUM_DESCR list).
  2425.  
  2426.         CURSOR : ENUM_ITEM_ACCESS;
  2427.         -- CURSOR will be moved through the ENUM_DESCR list
  2428.  
  2429.         COUNT, LAST : NATURAL;
  2430.         -- COUNT will be used to count how many times CURSOR
  2431.         -- has been moved one step
  2432.  
  2433.         ENUM_IMAGE_STRING : STRING (1 .. 4 * F77_ENUM'LENGTH);
  2434.         -- ENUM_IMAGE_STRING will be used to store the item image
  2435.         -- in an ADA format, since it is given in a FORTRAN77
  2436.         -- format (F77_ENUM parameter).
  2437.  
  2438.     begin
  2439.         COUNT := 0;
  2440.         CURSOR := ENUM_DESCR;
  2441.         ENUM_IMAGE_STRING := ADA_STRING (F77_ENUM, FALSE);
  2442.         LAST := ENUM_IMAGE_STRING'LAST;
  2443.  
  2444.         -- first compute LAST, which is the last meaningful
  2445.         -- character of the string (actually the last which
  2446.         -- is not equal to ASCII.NUL)
  2447.         while ENUM_IMAGE_STRING (LAST) = ASCII.NUL loop
  2448.             LAST := LAST - 1;
  2449.             if LAST = 0 then
  2450.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2451.                 "internal error when evaluating a value supposed to be");
  2452.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2453.                 "of an enumeration type");
  2454.                 raise LL_DAMES.X_INTERNAL_ERROR;
  2455.             end if;
  2456.         end loop;
  2457.         while CURSOR /= null loop
  2458. -- go through the list
  2459.  
  2460.             if CURSOR.all.ENUM_IMAGE (1 .. LAST) =
  2461.                ENUM_IMAGE_STRING (1 .. LAST) then
  2462.                 -- searched image is found
  2463.                 return COUNT;
  2464.             end if;
  2465.  
  2466.             COUNT := COUNT + 1;
  2467.             CURSOR := CURSOR.OTHER;
  2468.         end loop;
  2469.  
  2470.         -- if the loop ends while CURSOR = null, it means
  2471.         -- that the searched image has not been found.
  2472.         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2473.         "internal error when evaluating a value supposed to be");
  2474.         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2475.         "of an enumeration type");
  2476.         raise LL_DAMES.X_INTERNAL_ERROR;
  2477.     end ADA_ENUM;
  2478.  
  2479.  
  2480.  
  2481.     function ADA_SIZE (TABLE_ID, COMPONENT_ID : INTEGER) return INTEGER is
  2482.  
  2483.         -- ADA_SIZE returns the size (in 16 bits words) of the Ada type
  2484.         -- associated with the column defined by TABLE_ID and COMPONENT_ID
  2485.  
  2486.     begin
  2487.         case TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_TYPES (COMPONENT_ID) is
  2488.                 
  2489.                 -- INTEGER type
  2490.             when 1 =>  return 2;
  2491.  
  2492.                 -- FLOAT type
  2493.             when 2 =>  return 2;
  2494.  
  2495.                 -- CHARACTER SRING or ENUMERATION type
  2496.             when 5 => 
  2497.                 if TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES
  2498.                       (COMPONENT_ID) = null then
  2499.                         -- CHARACTER STRING type
  2500.                     return 15 +
  2501.                            TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_LENGTH
  2502.                               (COMPONENT_ID);
  2503.                 else
  2504.                         -- ENUMERATION type
  2505.                     return 1;
  2506.                 end if;
  2507.  
  2508.             when others =>
  2509.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2510.                 "internal error in a type definition evaluation");
  2511.                 raise LL_DAMES.X_INTERNAL_ERROR;
  2512.         end case;
  2513.     end ADA_SIZE;
  2514.     procedure POSITION (TABLE_ID, COMPONENT_ID : INTEGER;
  2515.                         KIND                   : OBJECT_TYPE;
  2516.                         FIRST_WORD, LAST_WORD  : in out INTEGER) is
  2517.  
  2518.                 -- POSITION returns in FIRST_WORD and LAST_WORD the numbers
  2519.                 -- of the first and of the last 16 bits words of the
  2520.                 -- component in the record, where record and component
  2521.                 -- are defined by TABLE_ID, COMPONENT_ID and KIND.
  2522.                 -- The first word of the record is number 1, and the
  2523.                 -- header of the component (if any) is not included
  2524.                 -- between the two returned positions.
  2525.  
  2526.         IC          : INTEGER;
  2527.         RECORD_NAME : STRING (1 .. NAME_LENGTH);
  2528.     begin
  2529.         FIRST_WORD := 1;
  2530.  
  2531.         case KIND is
  2532.           when WHOLE_TABLE =>
  2533.                 --    - the record to be considered is the one matching
  2534.                 --      the whole TABLE_ID table;
  2535.                 --    - the component to be considered is the column
  2536.                 --      number COMPONENT_ID of the table
  2537.  
  2538.             for I in 1 .. COMPONENT_ID - 1 loop
  2539.                 FIRST_WORD := FIRST_WORD + ADA_SIZE (TABLE_ID, I);
  2540.             end loop;
  2541.  
  2542.             LAST_WORD := FIRST_WORD + ADA_SIZE (TABLE_ID, COMPONENT_ID) - 1;
  2543.             if TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_TYPES
  2544.                 (COMPONENT_ID) = 5
  2545.                 and TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES
  2546.                 (COMPONENT_ID) = null then
  2547.                         -- character string component
  2548.  
  2549.                     FIRST_WORD := FIRST_WORD + 15;
  2550.             end if;
  2551.           when RECORD_COLUMN =>
  2552.                 --    - the record to be considered is the one matching
  2553.                 --      the record column to which the COMPONENT_ID scalar
  2554.                 --      column belongs;
  2555.                 --    - the component to be considered is the column
  2556.                 --      number COMPONENT_ID of the table
  2557.  
  2558.             IC := COMPONENT_ID - 1;
  2559.  
  2560.                 -- store in RECORD_NAME the name of the record column
  2561.                 -- to be considered
  2562.             RECORD_NAME := TABLE (TABLE_ID).TABLE_DEFINITION.IN_RECORD
  2563.                               (COMPONENT_ID);
  2564.  
  2565.             while IC /= 0 and then
  2566.         TABLE (TABLE_ID).TABLE_DEFINITION.IN_RECORD (IC) = RECORD_NAME loop
  2567.                         -- loop for each component of the record
  2568.                 FIRST_WORD := FIRST_WORD + ADA_SIZE (TABLE_ID, IC);
  2569.                 IC := IC - 1;
  2570.             end loop;
  2571.             LAST_WORD := FIRST_WORD + ADA_SIZE (TABLE_ID, COMPONENT_ID) - 1;
  2572.             if TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_TYPES
  2573.                 (COMPONENT_ID) = 5
  2574.                 and TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES
  2575.                 (COMPONENT_ID) = null then
  2576.                         -- character string component
  2577.  
  2578.                     FIRST_WORD := FIRST_WORD + 15;
  2579.             end if;
  2580.           when SCALAR_COLUMN =>
  2581.                 --  - The record to be considered is the one matching
  2582.                 --    the single scalar column defined by TABLE_ID and
  2583.                 --    COLUMN_ID;
  2584.                 --    - the component to be considered is the column
  2585.                 --      number COMPONENT_ID of the table
  2586.             LAST_WORD := ADA_SIZE (TABLE_ID, COMPONENT_ID);
  2587.             if LAST_WORD < 3 then
  2588.                         -- INTEGER, FLOAT or ENUMERATION column
  2589.                 FIRST_WORD := 1;
  2590.             else
  2591.                         -- CHARACTER STRING column
  2592.                 FIRST_WORD := 16;
  2593.             end if;
  2594.         end case;
  2595.     end POSITION;
  2596.  
  2597.     -------------------
  2598.     -- ADD_COMPONENT --
  2599.     -------------------
  2600.     procedure ADD_COMPONENT
  2601.                  (ADA_OBJECT             : in out USER_TYPE;
  2602.                   COMPONENT16            : INTEGER16_ARRAY_TYPE;
  2603.                   TABLE_ID, COMPONENT_ID : INTEGER;
  2604.                   KIND                   : OBJECT_TYPE) is
  2605.  
  2606.         -- ADD_COMPONENT copies the INTEGER16 array bit map of an
  2607.         -- ADA object into a particular place of the ADA_OBJECT object.
  2608.         -- Depending on the value of KIND, ADA_OBJECT is a record
  2609.         -- encapsulating all the columns of the TABLE_ID table, or is
  2610.         -- a record corresponding to a record column of the TABLE_ID
  2611.         -- table, or is a scalar Ada object corresponding to a scalar
  2612.         -- column of the TABLE_ID table.
  2613.         -- In each of these cases, COMPONENT_ID defines the scalar column
  2614.         -- corresponding to COMPONENT16.
  2615.  
  2616.         INTERNAL_ADA_OBJECT   : USER_TYPE;
  2617.         FIRST_WORD, LAST_WORD : INTEGER;
  2618.         type INTEGER16_ACCESS_TYPE is access INTEGER16;
  2619.         INTEGER16_ACCESS      : INTEGER16_ACCESS_TYPE;
  2620.  
  2621.         function INTEGER_TO_INTEGER16_ACCESS is new UNCHECKED_CONVERSION
  2622.                 (INTEGER, INTEGER16_ACCESS_TYPE);
  2623.  
  2624.     begin
  2625.         POSITION (TABLE_ID, COMPONENT_ID, KIND, FIRST_WORD, LAST_WORD);
  2626.  
  2627.                 -- The following instructions cannot be used directly
  2628.                 -- on the ADA_OBJECT object, since it is a formal
  2629.                 -- parameter instead of a current object; these two
  2630.                 -- instructions will then be used on another object
  2631.                 -- (called INTERNAL_ADA_OBJECT) which has been declared
  2632.                 -- in order to let these instructions work normally.
  2633.         INTERNAL_ADA_OBJECT := ADA_OBJECT;
  2634.  
  2635.         for I in FIRST_WORD .. LAST_WORD loop
  2636.             INTEGER16_ACCESS := INTEGER_TO_INTEGER16_ACCESS
  2637.                 (INTEGER (INTERNAL_ADA_OBJECT'ADDRESS) + I - 1);
  2638.             INTEGER16_ACCESS.all := COMPONENT16 (I - FIRST_WORD + 1);
  2639.         end loop;
  2640.         ADA_OBJECT := INTERNAL_ADA_OBJECT;
  2641.     end ADD_COMPONENT;
  2642.  
  2643.     -------------------
  2644.     -- GET_COMPONENT --
  2645.     -------------------
  2646.     procedure GET_COMPONENT (ADA_OBJECT             : USER_TYPE;
  2647.                              COMPONENT16            : out INTEGER16_ARRAY_TYPE;
  2648.                              TABLE_ID, COMPONENT_ID : INTEGER;
  2649.                              KIND                   : OBJECT_TYPE) is
  2650.  
  2651.         -- GET_COMPONENT copies an INTEGER16 array bit map of a part
  2652.         -- of the ADA_OBJECT object into COMPONENT16.
  2653.         -- Depending on the value of KIND, ADA_OBJECT is a record
  2654.         -- encapsulating all the columns of the TABLE_ID table, or is
  2655.         -- a record corresponding to a record column of the TABLE_ID
  2656.         -- table, or is a scalar Ada object corresponding to a scalar
  2657.         -- column of the TABLE_ID table.
  2658.         -- In each of these cases, COMPONENT_ID defines the scalar column
  2659.         -- corresponding to COMPONENT16.
  2660.  
  2661.         INTERNAL_ADA_OBJECT   : USER_TYPE;
  2662.         FIRST_WORD, LAST_WORD : INTEGER;
  2663.         type INTEGER16_ACCESS_TYPE is access INTEGER16;
  2664.         INTEGER16_ACCESS      : INTEGER16_ACCESS_TYPE;
  2665.  
  2666.         function INTEGER_TO_INTEGER16_ACCESS is new UNCHECKED_CONVERSION
  2667.                 (INTEGER, INTEGER16_ACCESS_TYPE);
  2668.  
  2669.     begin
  2670.         POSITION (TABLE_ID, COMPONENT_ID, KIND, FIRST_WORD, LAST_WORD);
  2671.  
  2672.                 -- The following instructions cannot be used directly
  2673.                 -- on the ADA_OBJECT object, since it is a formal
  2674.                 -- parameter instead of a current object; these two
  2675.                 -- instructions will then be used on another object
  2676.                 -- (called INTERNAL_ADA_OBJECT) which has been declared
  2677.                 -- in order to let these instructions work normally.
  2678.         INTERNAL_ADA_OBJECT := ADA_OBJECT;
  2679.  
  2680.         for I in FIRST_WORD .. LAST_WORD loop
  2681.             INTEGER16_ACCESS := INTEGER_TO_INTEGER16_ACCESS
  2682.                 (INTEGER (INTERNAL_ADA_OBJECT'ADDRESS) + I - 1);
  2683.             COMPONENT16 (I - FIRST_WORD + 1) := INTEGER16_ACCESS.all;
  2684.         end loop;
  2685.     end GET_COMPONENT;
  2686.  
  2687.  
  2688. end CONVERSION;
  2689. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2690. --lldames.txt
  2691. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2692. with SHARE;
  2693. -- SHARE is a package containing a boolean variable (A_DATABASE_IS_OPEN)
  2694. -- shared by LL_DAMES and DAMES
  2695.  
  2696. with F77_CALLABLES;
  2697. -- F77_CALLABLES contains the FORTRAN77 subroutines used to access 
  2698. -- the databases
  2699.  
  2700. with UNCHECKED_CONVERSION;
  2701.  
  2702. with TABLE_DESCRIPTOR;
  2703. use TABLE_DESCRIPTOR;
  2704. -- TABLE_DESCRIPTOR contains type declarations and a complex variable
  2705. -- declaration, this variable containing the definition and status of
  2706. -- all currently locked tables
  2707.  
  2708. with CONVERSION;
  2709. -- CONVERSION contains procedures and functions to be  used  mainly
  2710. -- for types conversions
  2711.  
  2712. with UTILITIES;
  2713. -- UTILITIES contains procedures and functions which are to be used
  2714. -- in order to access the variables of the TABLE_DESCRIPTOR package.
  2715.  
  2716. with ADA_TABLES;
  2717. -- ADA_TABLES is an interface to the three reserved tables of the
  2718. -- interface manager (which are called ADARANGE, ADARECORD and ADAENUM)
  2719.  
  2720. with PARSE;
  2721. -- PARSE contains a parser used by the DEFINE_TABLE procedure
  2722.  
  2723. package body LL_DAMES is
  2724.  
  2725. -------------------------used by UPDATE and INSERT------------------------
  2726.  
  2727.  
  2728.  
  2729.     procedure SORTED_INSERT (TABLE_ID : INTEGER) is
  2730.  
  2731. -- SORTED_INSERT is used to add a new row to a sorted table so
  2732. -- that the table remains sorted;
  2733. -- The keys of the table are first found, and the position where
  2734. -- the new row is to be inserted is then chosen by comparing the
  2735. -- keys values of the new row to those of the actual rows of the
  2736. -- table (this is performed by using the DFIND function); the
  2737. -- new row is then inserted, by using the DADD function.
  2738.  
  2739.  
  2740. -- following declarations are those of the FORTRAN77 arguments
  2741. -- to be used :
  2742.         SAVE_ROW                     : INTEGER_ARRAY_TYPE
  2743.                                                 (1 .. MAX_STRING);
  2744.         ACSIFO                       : INTEGER_ARRAY_TYPE (1 .. 22);
  2745.         KEY_ID, KYIDX, KYTLEN, KYTYP : INTEGER_ARRAY_TYPE (1 .. 5);
  2746.         VALUE                        : INTEGER_ARRAY_TYPE
  2747.                                          (1 .. (3 + MAX_STRING) / 4) :=
  2748.                                        (others => 0);
  2749.         KYVAL0                       : STRING (1 .. 800) :=
  2750.                                        (others => ASCII.NUL);
  2751.         KYNAM                        : STRING (1 .. 60) := (others => ' ');
  2752.         ATNAM                        : STRING
  2753.                                          (1 .. 12 *
  2754.                                                TABLE (TABLE_ID).TABLE_DEFINITION
  2755.                                                 .COLUMN_NUMBER) :=
  2756.                                        (others => ' ');
  2757.         LENR, FTYP, RTN              : INTEGER;
  2758.  
  2759.         function ROW_SIZE return INTEGER is
  2760.  
  2761.             -- ROW_SIZE computes the actual size (in bytes) of the
  2762.             -- row of the TABLE_ID table, and returns it.
  2763.  
  2764.             TO_BE_RETURNED : INTEGER := 0;
  2765.         begin
  2766.             for I in 1 .. TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NUMBER
  2767.                                                         loop
  2768.                 if TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_TYPES (I) = 5
  2769.                                                         then
  2770.                     TO_BE_RETURNED := TO_BE_RETURNED +
  2771.                      TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_LENGTH (I);
  2772.                 else
  2773.                     TO_BE_RETURNED := TO_BE_RETURNED + 4;
  2774.                 end if;
  2775.             end loop;
  2776.             return TO_BE_RETURNED;
  2777.         end ROW_SIZE;
  2778.     begin
  2779.         -- save the value of the row to be added to the table
  2780.         F77_CALLABLES.ADA_GETTB (TABLE (TABLE_ID).TABLE_STATUS.DESCR,
  2781.                 SAVE_ROW, 4 * MAX_STRING);
  2782.  
  2783.         -- read in ACSIFO which columns are the sort keys
  2784.         F77_CALLABLES.ADA_FACSS (TABLE (TABLE_ID).TABLE_STATUS.DESCR, ACSIFO);
  2785.  
  2786.         for I in 1 .. ACSIFO (2) loop
  2787.             -- loop one time for each key
  2788.  
  2789.  
  2790.             -- store in KEY_ID the index to TABLE of the key
  2791.             KEY_ID (I) := UTILITIES.SCALAR_COLUMN_ID
  2792.                              (TABLE_ID,
  2793.                               CONVERSION.ADA_STRING
  2794.                                  (ACSIFO (3 * I .. 3 * I + 2), FALSE));
  2795.  
  2796.             -- store in KYIDX the FORTRAN77 index of the key
  2797.             KYIDX (I) := TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_INDEX
  2798.                             (KEY_ID (I));
  2799.  
  2800.             -- store in KYNAM the name of the key
  2801.             KYNAM (12 * I - 11 .. 12 * I - 12 + NAME_LENGTH) :=
  2802.               TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NAMES (KEY_ID (I));
  2803.  
  2804.             -- store in KYTLEN the length of the key
  2805.             KYTLEN (I) := TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_LENGTH
  2806.                              (KEY_ID (I));
  2807.  
  2808.             -- store in KYTYP the type of the key
  2809.             KYTYP (I) := TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_TYPES
  2810.                             (KEY_ID (I));
  2811.  
  2812.             -- get into VALUE the actual value of the key of the temporary
  2813.             -- row to be inserted
  2814.             F77_CALLABLES.ADA_GETA
  2815.                (TABLE (TABLE_ID).TABLE_STATUS.DESCR, KYIDX (I), VALUE, LENR,
  2816.                 FTYP, RTN);
  2817.             if RTN /= 0 then
  2818.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2819.                 "internal error during insertion into a sorted table");
  2820.                 raise X_INTERNAL_ERROR;
  2821.             end if;
  2822.  
  2823.             -- convert VALUE into the KYVAL0 character string
  2824.             KYVAL0 (160 * I - 159 .. 160 * I - 160 + MAX_STRING) :=
  2825.               CONVERSION.ADA_STRING (VALUE, FALSE);
  2826.         end loop;
  2827.  
  2828.         -- find the position where the new row is to be inserted
  2829.         F77_CALLABLES.ADA_DFIND
  2830.            (TABLE (TABLE_ID).TABLE_STATUS.DESCR, 0, KYIDX (1 .. ACSIFO (2)),
  2831.             KYVAL0 (1 .. ACSIFO (2) * 160), ACSIFO (2),
  2832.             TABLE (TABLE_ID).TABLE_STATUS.CURRENT_ROW, 0, RTN);
  2833.  
  2834.         if RTN = -2 or RTN = -3 then
  2835.             TABLE (TABLE_ID).TABLE_STATUS.CURRENT_ROW (1) := -1;
  2836.         end if;
  2837.         for I in 1 .. TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NUMBER loop
  2838.             -- convert the TABLE column names list into the ATNAM column
  2839.             -- names list
  2840.             ATNAM (12 * I - 11 .. 12 * I - 12 + NAME_LENGTH) :=
  2841.               TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NAMES (I);
  2842.         end loop;
  2843.  
  2844.         -- restore the value of the row to be added to the table
  2845.         F77_CALLABLES.ADA_PUTTB (TABLE (TABLE_ID).TABLE_STATUS.DESCR,
  2846.                 SAVE_ROW, (ROW_SIZE + 3) / 4);
  2847.  
  2848.         -- actually insert the temporary row 
  2849.         F77_CALLABLES.ADA_DADD
  2850.            (TABLE (TABLE_ID).TABLE_STATUS.DESCR, KYNAM (1 .. 12 * ACSIFO (2)),
  2851.             KYIDX (1 .. ACSIFO (2)), KYVAL0 (1 .. 160 * ACSIFO (2)),
  2852.             ACSIFO (2), KYTLEN (1 .. ACSIFO (2)), KYTYP (1 .. ACSIFO (2)),
  2853.             ATNAM,
  2854.             TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_INDEX
  2855.                (1 .. TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NUMBER),
  2856.             TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NUMBER,
  2857.             TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_LENGTH
  2858.                (1 .. TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NUMBER),
  2859.             TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_TYPES
  2860.                (1 .. TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NUMBER),
  2861.             TABLE (TABLE_ID).TABLE_STATUS.CURRENT_ROW, RTN);
  2862.             if RTN /= 0 then
  2863.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2864.                 "internal error during insertion into a sorted table");
  2865.                 raise X_INTERNAL_ERROR;
  2866.             end if;
  2867.     end SORTED_INSERT;
  2868.  
  2869.     procedure OPEN (DB_NAME : STRING) is
  2870. --************************************************************************
  2871. --**                                                                    **
  2872. --**   UNIT NAME :          OPEN                                        **
  2873. --**   ~~~~~~~~~~~                                                      **
  2874. --** DESCRIPTION--------------------------------------------------------**
  2875. --**                                                                    **
  2876. --**                                                                    **
  2877. --**    if A_DATABASE_IS_OPEN then                                      **
  2878. --**        raise X_OPEN_DATABASE;                                      **
  2879. --**    end if;                                                         **
  2880. --**                                                                    **
  2881. --**    OPEN_DATABASE (DB_NAME);                                        **
  2882. --**                                                                    **
  2883. --**    if ERROR then                                                   **
  2884. --**        raise X_CANT_ACCESS_DATABASE;                               **
  2885. --**    end if;                                                         **
  2886. --**                                                                    **
  2887. --**    A_DATABASE_IS_OPEN := TRUE;                                     **
  2888. --**                                                                    **
  2889. --**                                                                    **
  2890. --** INPUT--------------------------------------------------------------**
  2891. --**                                                                    **
  2892. --**  DB_NAME is the name of the database to be open.                   **
  2893. --**                                                                    **
  2894. --** STATUS VARIABLES USED----------------------------------------------**
  2895. --**                                                                    **
  2896. --**    A_DATABASE_IS_OPEN                                              **
  2897. --**                                                                    **
  2898. --** OUTPUT-------------------------------------------------------------**
  2899. --**                                                                    **
  2900. --**                                                                    **
  2901. --** STATUS VARIABLES UPDATED-------------------------------------------**
  2902. --**                                                                    **
  2903. --**    A_DATABASE_IS_OPEN                                              **
  2904. --**                                                                    **
  2905. --** EXCEPTIONS---------------------------------------------------------**
  2906. --**                                                                    **
  2907. --**    X_OPEN_DB                                                       **
  2908. --**    X_CANT_ACCESS_DB                                                **
  2909. --**                                                                    **
  2910. --************************************************************************
  2911.         RTN : INTEGER;
  2912.     begin
  2913.         if SHARE.A_DATABASE_IS_OPEN then
  2914.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2915.             "No database should be already opened when trying to open one");
  2916.             raise X_OPEN_DB;
  2917.         end if;
  2918.  
  2919.         F77_CALLABLES.ADA_DOPENDB (UTILITIES.NORMALIZE (DB_NAME), RTN);
  2920.  
  2921.         if RTN /= 0 then
  2922.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2923.             "The requested database is not on line, does not exist, or can");
  2924.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  2925.             "not be accessed ");
  2926.             raise X_CANT_ACCESS_DB;
  2927.         end if;
  2928.  
  2929.         SHARE.A_DATABASE_IS_OPEN := TRUE;
  2930.         SHARE.OPEN_DATABASE_NAME := UTILITIES.NORMALIZE (DB_NAME);
  2931.     end OPEN;
  2932.  
  2933.     procedure DEFINE_TABLE (TABLE_NAME : STRING; COLUMN_LIST : STRING) is
  2934. --************************************************************************
  2935. --**                                                                    **
  2936. --**   UNIT NAME :          DEFINE_TABLE                                **
  2937. --**   ~~~~~~~~~~~                                                      **
  2938. --** DESCRIPTION--------------------------------------------------------**
  2939. --**                                                                    **
  2940. --**                                                                    **
  2941. --**    if not A_DATABASE_IS_OPEN then                                  **
  2942. --**        raise X_NO_OPEN_DB;                                         **
  2943. --**    end if;                                                         **
  2944. --**                                                                    **
  2945. --**    INITIALIZE_TABLE_CREATION (TABLE_NAME);                         **
  2946. --**        -- this step is performed by using  the  IRELC  access      **
  2947. --**        -- procedure.                                               **
  2948. --**                                                                    **
  2949. --**    PARSE_FIRST_LEVEL (COLUMN_LIST);                                **
  2950. --**        -- this step generates a call to the ADDATR access procedure**
  2951. --**        -- for each of the DAMES column to be created.              **
  2952. --**        -- PARSE_FIRST_LEVEL can detect any  syntactic  error  of   **
  2953. --**        -- COLUMN_LIST.                                             **
  2954. --**    if ERROR then                                                   **
  2955. --**        CANCEL_TABLE_CREATION;                                      **
  2956. --**        raise X_INVALID_COLUMN;                                     **
  2957. --**    end if;                                                         **
  2958. --**                                                                    **
  2959. --**    CONFIRM_TABLE_CREATION;                                         **
  2960. --**    if ERROR then                                                   **
  2961. --**        raise X_CANT_ACCESS_TABLE;                                  **
  2962. --**    end if;                                                         **
  2963. --**                                                                    **
  2964. --**    if ADA_INTERFACE_TABLES_DO_NOT_EXIST then                       **
  2965. --**            -- the three tables ADARANGE, ADARECORD and ADAENUM  do **
  2966. --**            -- not already exist; they have to be created.          **
  2967. --**        CREATE_ADA_INTERFACE_TABLES;                                **
  2968. --**    end if;                                                         **
  2969. --**                                                                    **
  2970. --**    PARSE_SECOND_LEVEL (COLUMN_LIST);                               **
  2971. --**        -- the information to be stored in ADARANGE, ADARECORD and  **
  2972. --**        -- ADAENUM tables of the database is the one provided by    **
  2973. --**        -- PARSE_SECOND_LEVEL for each concerned column, and is     **
  2974. --**        -- composed of : column range (if any), name of the record  **
  2975. --**        -- the column belongs to (if any), and list of values for an**
  2976. --**        -- enumeration type column.                                 **
  2977. --**                                                                    **
  2978. --** INPUT--------------------------------------------------------------**
  2979. --**                                                                    **
  2980. --**          * TABLE_NAME is the name of the table to be created.      **
  2981. --**                                                                    **
  2982. --**          * COLUMN_LIST   is  a  string describing the table;  the  **
  2983. --**  column descriptors are separated with semi-colons ; each  column  **
  2984. --**  descriptor is a string describing the name,  type,  and optional  **
  2985. --**  constraint  of  the  column;  the  following form is to be  used  **
  2986. --**  (B.N.F. notation) :                                               **
  2987. --**    COLUMN_LIST    := <column_descr> {; <column_descr> }            **
  2988. --**    <column_descr> := <scalar_descr> | <record_descr>               **
  2989. --**    <record_descr> := <name> <scalar_descr> {, <scalar_descr>}      **
  2990. --**    <scalar_descr> := <name> [<type>]                               **
  2991. --**    <name> is a valid column name                                   **
  2992. --**    <type>         := STRING [(1 .. n)] |                           **
  2993. --**                      FLOAT  [<constraint>] |                       **
  2994. --**                      INTEGER [<constraint>] |                      **
  2995. --**                      <enumeration_type_definition> [<constraint>]  **
  2996. --**    <constraint>   := RANGE <value> .. <value>                      **
  2997. --**    <value> is a literal the type of which depends on the           **
  2998. --**                      associated  type                              **
  2999. --**    <enumeration_type_definition> is defined with this name in the  **
  3000. --**                      ADA  Reference  Manual ;  it  is  a  list of  **
  3001. --**                      enumeration litterals separated by commas and **
  3002. --**                      enclosed in parenthesese.                     **
  3003. --**                                                                    **
  3004. --**                                                                    **
  3005. --** STATUS VARIABLES USED----------------------------------------------**
  3006. --**                                                                    **
  3007. --**    A_DATABASE_IS_OPEN                                              **
  3008. --**                                                                    **
  3009. --** OUTPUT-------------------------------------------------------------**
  3010. --**                                                                    **
  3011. --**                                                                    **
  3012. --** STATUS VARIABLES UPDATED-------------------------------------------**
  3013. --**                                                                    **
  3014. --**                                                                    **
  3015. --** EXCEPTIONS---------------------------------------------------------**
  3016. --**                                                                    **
  3017. --**    X_NO_OPEN_DB                                                    **
  3018. --**    X_INVALID_COLUMN                                                **
  3019. --**    X_CANT_ACCESS_TABLE                                             **
  3020. --**                                                                    **
  3021. --************************************************************************
  3022.         RTN, RCKEY  : INTEGER;
  3023.         TABLE_NAME2 : STRING (1 .. NAME_LENGTH);
  3024.     begin
  3025.         if not SHARE.A_DATABASE_IS_OPEN then
  3026.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3027.             "The database in which a table is to be created must be opened");
  3028.             raise X_NO_OPEN_DB;
  3029.         end if;
  3030.  
  3031.         -- lock the main DAMES reserved table
  3032.         F77_CALLABLES.ADA_SETLK (SHARE.OPEN_DATABASE_NAME);
  3033.  
  3034.         -- normalize the table name
  3035.         TABLE_NAME2 := UTILITIES.NORMALIZE (TABLE_NAME);
  3036.  
  3037.         -- initialize the table creation
  3038.         F77_CALLABLES.ADA_IRELC (TABLE_NAME2, RCKEY, 1);
  3039.  
  3040.         -- parse a first time the column list to define each scalar
  3041.         -- column as seen by the FORTRAN77 and User Language interfaces
  3042.         PARSE.PARSE_FIRST_LEVEL (COLUMN_LIST, RCKEY);
  3043.  
  3044.         -- terminate the table creation
  3045.         F77_CALLABLES.ADA_TRELC (RCKEY, 1, 0, 0, RTN);
  3046.         F77_CALLABLES.ADA_RELLK (SHARE.OPEN_DATABASE_NAME);
  3047.  
  3048.         if RTN /= 0 then
  3049.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3050.             "The " & TABLE_NAME & " table can not be created");
  3051.             raise X_CANT_ACCESS_TABLE;
  3052.         end if;
  3053.  
  3054.         -- lock the three reserved tables in exclusive mode or create
  3055.         -- them if they do not exist
  3056.         ADA_TABLES.LOCK_ADA_TABLES_IN_EXCLUSIVE_MODE (TABLE_NAME2);
  3057.  
  3058.         -- add into the three reserved tables the rows defining the 
  3059.         -- record columns, the enumeration type columns, or the range
  3060.         -- constraints proper to the currently created table and to
  3061.         -- the Ada Interface Manager
  3062.         PARSE.PARSE_SECOND_LEVEL (COLUMN_LIST);
  3063.  
  3064.         -- release the reserved tables locks
  3065.         ADA_TABLES.UNLOCK_ADA_TABLES;
  3066.     exception
  3067.         when PARSE.X_SYNTAX_ERROR => 
  3068. -- X_SYNTAX_ERROR is raised when a syntax error is detected
  3069. -- during the parsing of the COLUMN_LIST sentence; this can
  3070. -- occur during PARSE_FIRST_LEVEL only, and the table creation
  3071. -- must then be cancelled
  3072.             F77_CALLABLES.ADA_TRELC (RCKEY, 2, 0, 0, RTN);
  3073.             F77_CALLABLES.ADA_RELLK (SHARE.OPEN_DATABASE_NAME);
  3074.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3075.             "There is a syntax error in COLUMN_LIST");
  3076.             raise X_INVALID_COLUMN;
  3077.     end DEFINE_TABLE;
  3078.  
  3079.  
  3080.     procedure LOCK (LOCK_LIST : LOCK_LIST_TYPE) is
  3081. --************************************************************************
  3082. --**                                                                    **
  3083. --**   UNIT NAME :          LOCK                                        **
  3084. --**   ~~~~~~~~~~~                                                      **
  3085. --** DESCRIPTION--------------------------------------------------------**
  3086. --**                                                                    **
  3087. --**    if not A_DATABASE_IS_OPEN then                                  **
  3088. --**        raise X_NO_OPEN_DB;                                         **
  3089. --**    end if;                                                         **
  3090. --**                                                                    **
  3091. --**    CLOSE_TABLES;                                                   **
  3092. --**        -- close already open tables, if any                        **
  3093. --**                                                                    **
  3094. --**    UNLOCK_TABLES;                                                  **
  3095. --**        -- unlock already locked tables, if any                     **
  3096. --**                                                                    **
  3097. --**    for TABLE_NAME in TABLE'FIRST .. TABLE'LAST loop                **
  3098. --**                                                                    **
  3099. --**            -- TABLE'FIRST .. TABLE'LAST is the list of all known   **
  3100. --**            -- tables; all have been unlocked by the previous       **
  3101. --**            -- call to UNLOCK_TABLES, and this will be noticed by   **
  3102. --**            -- setting all LOCK components of the TABLE status array**
  3103. --**            -- to 'unlocked'                                        **
  3104. --**                                                                    **
  3105. --**        UPDATE_TABLE_NAME_LOCK_STATUS;                              **
  3106. --**    end loop;                                                       **
  3107. --**                                                                    **
  3108. --**    SET_LOCKS (ADARANGE, ADAENUM, ADARECORD);                       **
  3109. --**                                                                    **
  3110. --**    GET_ADA_INTERFACE_INFORMATION_FROM_DATABASE (TABLE_NAME_LIST);  **
  3111. --**        -- TABLE_NAME_LIST is the list of the tables to be          **
  3112. --**        -- locked; it has been extracted from the LOCK_LIST         **
  3113. --**        -- argument. GET_ADA_INTERFACE_INFORMATION_FROM_DATABASE    **
  3114. --**        -- reads from reserved tables of the database some          **
  3115. --**        -- additionnal information relative to the TABLE_NAME_LIST  **
  3116. --**        -- tables and used by the Ada Interface Manager only.       **
  3117. --**        -- These reserved tables are ADARANGE, ADARECORD and ADAENUM**
  3118. --**                                                                    **
  3119. --**    UNLOCK_TABLES;                                                  **
  3120. --**        -- unlock the three reserved tables of the interface        **
  3121. --**                                                                    **
  3122. --**    SET_LOCKS (TABLE_NAME_LIST);                                    **
  3123. --**    if ERROR then                                                   **
  3124. --**        raise X_CANT_ACCESS_TABLE;                                  **
  3125. --**    end if;                                                         **
  3126. --**                                                                    **
  3127. --**    for TABLE_NAME in TABLE_NAME_LIST loop                          **
  3128. --**                                                                    **
  3129. --**            -- TABLE_NAME_LIST is the list of the tables to be      **
  3130. --**            -- locked; it has been extracted from the LOCK_LIST     **
  3131. --**            -- argument.                                            **
  3132. --**                                                                    **
  3133. --**        OPEN_TABLE (TABLE_NAME);                                    **
  3134. --**        if ERROR then                                               **
  3135. --**                                                                    **
  3136. --**            for INNER_LOOP_TABLE_NAME in TABLE_NAME_LIST'FIRST      **
  3137. --**                                      .. TABLE_NAME_LIST'LAST loop  **
  3138. --**                                                                    **
  3139. --**                RESET_INNER_LOOP_TABLE_NAME_STATUS;                 **
  3140. --**                    -- reset the LOCK component of                  **
  3141. --**                    -- INNER_LOOP_TABLE_NAME in the TABLE status    **
  3142. --**                    -- array to 'unlocked'                          **
  3143. --**            end loop;                                               **
  3144. --**                                                                    **
  3145. --**            for INNER_LOOP_TABLE_NAME in TABLE_NAME_LIST'FIRST      **
  3146. --**                                         .. TABLE_NAME'PRED loop    **
  3147. --**                                                                    **
  3148. --**                CLOSE_TABLE (INNER_LOOP_TABLE_NAME);                **
  3149. --**            end loop;                                               **
  3150. --**            UNLOCK_TABLES;                                          **
  3151. --**            raise X_CANT_ACCESS_TABLE;                              **
  3152. --**        end if;                                                     **
  3153. --**                                                                    **
  3154. --**        INITIALIZE_CURRENT_ROW;                                     **
  3155. --**            -- call the SETGET access procedure to select all rows  **
  3156. --**            -- and set the CURRENT_ROW component of TABLE_NAME in   **
  3157. --**            -- the TABLE status array to 'init'.                    **
  3158. --**                                                                    **
  3159. --**        UPDATE_TABLE (TABLE_NAME);                                  **
  3160. --**            -- set the LOCK component to 'shared' or 'exclusive',   **
  3161. --**            -- depending on the LOCK_LIST actual argument.          **
  3162. --**                                                                    **
  3163. --**        GET_DAMES_INFORMATION_FROM_DATABASE (TABLE_NAME);           **
  3164. --**            -- read from the database files and from the relation   **     
  3165. --**            -- relation the description of  TABLE_NAME  as seen     **
  3166. --**            -- by the DAMES dbms without Ada interface.             **
  3167. --**            -- In particular, the DGINFO fortran subroutine will be **
  3168. --**            -- called to get the values of the index of each column **
  3169. --**            -- as the accessible Fortran routines do not use column **
  3170. --**            -- names for column identification but  use  an  index. **
  3171. --**            -- Each time a column definition is read, the additional**
  3172. --**            -- information  (if  any)  previously  read  from  Ada  **
  3173. --**            -- Interface reserved tables is linked to the basic     **
  3174. --**            -- information just read.                               **
  3175. --**                                                                    **
  3176. --**    end loop;                                                       **
  3177. --**                                                                    **
  3178. --**                                                                    **
  3179. --** INPUT--------------------------------------------------------------**
  3180. --**                                                                    **
  3181. --**  LOCK_LIST  is  an array  of  LOCK_TYPE  records,  each  of  them  **
  3182. --**  describing a single lock; the two components of a LOCK_TYPE  are  **
  3183. --**  TABLE_NAME,  which  identifies  a  table, and ACCESS_MODE, which  **
  3184. --**  describes in which mode (shared or exclusive) the table is to be  **
  3185. --**  accessed.                                                         **
  3186. --**                                                                    **
  3187. --** STATUS VARIABLES USED----------------------------------------------**
  3188. --**                                                                    **
  3189. --**    A_DATABASE_IS_OPEN                                              **
  3190. --**                                                                    **
  3191. --** OUTPUT-------------------------------------------------------------**
  3192. --**                                                                    **
  3193. --**                                                                    **
  3194. --** STATUS VARIABLES UPDATED-------------------------------------------**
  3195. --**                                                                    **
  3196. --**    TABLE                                                           **
  3197. --**                                                                    **
  3198. --** EXCEPTIONS---------------------------------------------------------**
  3199. --**                                                                    **
  3200. --**    X_CANT_ACCESS_TABLE                                             **
  3201. --**    X_NO_OPEN_DB                                                    **
  3202. --**                                                                    **
  3203. --************************************************************************
  3204.  
  3205.         TABLE_NUMBER                 : INTEGER := LOCK_LIST'LENGTH;
  3206.         INDEX                        : INTEGER;
  3207.         INDEX2, INDEX1               : array (1 .. TABLE_NO) of INTEGER;
  3208.         COLNAME, RECORD_NAME         : STRING (1 .. NAME_LENGTH);
  3209.         TABLE_NAME2                  : array (1 .. TABLE_NUMBER)
  3210.                                               of STRING (1 .. NAME_LENGTH);
  3211.         MINVALUE, MAXVALUE           : STRING (1 .. RANGE_SIZE);
  3212.         ACSIFO                       : INTEGER_ARRAY_TYPE (1 .. 22);
  3213.         ATTL, DESCR, RTN, ENUM_VALUE : INTEGER;
  3214.         CURSOR,PREVIOUS_CURSOR       : ENUM_ITEM_ACCESS;
  3215.  
  3216.         ATNAM                        : STRING (1 .. 12 * COL_NO);
  3217.         ATIDX, ATTYP, ATLEN          : INTEGER_ARRAY_TYPE (1 .. COL_NO);
  3218.         TIDD                         : TIDD_TYPE;
  3219.         IMAGE_STRING                 : STRING (1 .. IMAGE_SZ);
  3220.         EOF                          : BOOLEAN;
  3221.         RELIST                       : STRING (1 .. 12 * TABLE_NUMBER);
  3222.         MODLIS                       : INTEGER_ARRAY_TYPE (1 .. TABLE_NUMBER);
  3223.  
  3224.     begin
  3225.         if not SHARE.A_DATABASE_IS_OPEN then
  3226.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3227.             "The database containing the tables to be locked must previously");
  3228.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3229.             "be opened");
  3230.             raise X_NO_OPEN_DB;
  3231.         end if;
  3232.  
  3233.         for I in 1 .. TABLE_NUMBER loop
  3234.             -- first normalize the table names of those to be locked
  3235.             TABLE_NAME2 (I) :=
  3236.               UTILITIES.NORMALIZE
  3237.                  (LOCK_LIST (LOCK_LIST'FIRST - 1 + I).TABLE_NAME);
  3238.         end loop;
  3239.  
  3240.         -- close all previously open tables
  3241.         F77_CALLABLES.ADA_CLRELS;
  3242.  
  3243.         -- release all previously set locks
  3244.         F77_CALLABLES.ADA_DUNLK;
  3245.  
  3246.         for I in 1 .. TABLE_NO loop
  3247.             TABLE (I).TABLE_STATUS.TABLE_IS_LOCKED := FALSE;
  3248.         end loop;
  3249.  
  3250.         -- lock the three reserved tables in shared mode
  3251.         ADA_TABLES.LOCK_ADA_TABLES_IN_SHARED_MODE;
  3252. -----------------------get the range constraints information--------------
  3253.  
  3254.         -- open the ADARANGE reserved table
  3255.         ADA_TABLES.OPEN_ADA_TABLE ("ADARANGE  ");
  3256.  
  3257.         for I in 1 .. TABLE_NUMBER loop
  3258.             -- for each of the tables to be locked
  3259.  
  3260.             -- select in ADARANGE the information relative to
  3261.             -- TABLE_NAME2(I)
  3262.             ADA_TABLES.RESET_ADA_TABLE (TABLE_NAME2 (I));
  3263.  
  3264.             TABLE (I).TABLE_DEFINITION.COLUMN_NAMES :=
  3265.               (others => (others => ' '));
  3266.         for J in 1 .. COL_NO loop
  3267.                 if TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J) /= null then
  3268.             STORE_CONSTRAINT (TABLE (I).TABLE_DEFINITION.
  3269.                             CONSTRAINTS (J));
  3270.             TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J) := null;
  3271.             end if;
  3272.         end loop;
  3273.             INDEX1 (I) := 0;
  3274.  
  3275.             loop
  3276.                 -- for each information of ADARANGE (i.e. a range
  3277.                 -- constraint definition for one column)
  3278.  
  3279.                 -- get this range constraint definition
  3280.                 ADA_TABLES.GET_RANGE (COLNAME, MINVALUE, MAXVALUE, EOF);
  3281.                 exit when EOF;
  3282.  
  3283.                 -- add it in the TABLE variable
  3284.                 INDEX1 (I) := INDEX1 (I) + 1;
  3285.                 TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (INDEX1 (I)) := COLNAME;
  3286.                 TABLE (I).TABLE_DEFINITION.CONSTRAINTS (INDEX1 (I)) :=
  3287.                   NEW_CONSTRAINT;
  3288.                 TABLE (I).TABLE_DEFINITION.CONSTRAINTS (INDEX1 (I)).all :=
  3289.                   MINVALUE & MAXVALUE;
  3290.             end loop;
  3291.         end loop;
  3292.  
  3293.         ADA_TABLES.CLOSE_ADA_TABLE;
  3294. -------------------get the record columns definitions---------------------
  3295.  
  3296.         -- open the ADARECORD reserved table
  3297.         ADA_TABLES.OPEN_ADA_TABLE ("ADARECORD ");
  3298.  
  3299.         for I in 1 .. TABLE_NUMBER loop
  3300.             -- for each of the tables to be locked
  3301.  
  3302.             -- select all ADARECORD rows relative to the TABLE_NAME2(I)
  3303.             -- table
  3304.             ADA_TABLES.RESET_ADA_TABLE (TABLE_NAME2 (I));
  3305.  
  3306.             TABLE (I).TABLE_DEFINITION.IN_RECORD := (others => (others => ' '));
  3307.  
  3308.             loop
  3309.                 -- get each ADARECORD row information (i.e. the name of a
  3310.                 -- record column with the name of one of its components)
  3311.                 ADA_TABLES.GET_RECORD (RECORD_NAME, COLNAME, EOF);
  3312.                 exit when EOF;
  3313.  
  3314.                 -- look how the new information(the component of the record
  3315.                 -- column) is to be inserted : as a new column definition
  3316.                 -- if the COLNAME column is unknown, or as an additionnal 
  3317.                 -- information to that already provided about this column
  3318.                 -- if it already exists
  3319.                 for II in 1 .. INDEX1 (I) + 1 loop
  3320.                     INDEX2 (I) := II;
  3321.                     exit when COLNAME =
  3322.                               TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (II);
  3323.                 end loop;
  3324.  
  3325.                 -- the Ith scalar column belongs to the RECORD_NAME record
  3326.                 -- column
  3327.                 TABLE (I).TABLE_DEFINITION.IN_RECORD (INDEX2 (I)) :=
  3328.                   RECORD_NAME;
  3329.  
  3330.                 if INDEX2 (I) = INDEX1 (I) + 1 then
  3331.                     TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (INDEX2 (I)) :=
  3332.                       COLNAME;
  3333.                     INDEX1 (I) := INDEX2 (I);
  3334.                 end if;
  3335.             end loop;
  3336.         end loop;
  3337.  
  3338.         ADA_TABLES.CLOSE_ADA_TABLE;
  3339. ------------------get the enumeration type columns definitions------------
  3340.  
  3341.         -- open the ADAENUM reserved table
  3342.         ADA_TABLES.OPEN_ADA_TABLE ("ADAENUM   ");
  3343.  
  3344.         for I in 1 .. TABLE_NUMBER loop
  3345.             -- for each of the tables to be locked
  3346.  
  3347.             -- select in ADAENUM all rows relative to TABLE_NAME2 (I)
  3348.             ADA_TABLES.RESET_ADA_TABLE (TABLE_NAME2 (I));
  3349.  
  3350.             TABLE (I).TABLE_DEFINITION.ENUM_TYPES := (others => null);
  3351.  
  3352.             loop
  3353.                 -- for each row defining a particular value of a particular
  3354.                 -- enumeration type definition
  3355.  
  3356.                 -- get the position and image of an item, and the name
  3357.                 -- of the enumeration column it belongs to
  3358.                 ADA_TABLES.GET_ENUM (COLNAME, ENUM_VALUE, IMAGE_STRING, EOF);
  3359.                 exit when EOF;
  3360.  
  3361.                 -- look for the place where the new definition item is to
  3362.                 -- be inserted
  3363.                 for II in 1 .. INDEX1 (I) + 1 loop
  3364.                     INDEX2 (I) := II;
  3365.                     exit when COLNAME =
  3366.                               TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (II);
  3367.                 end loop;
  3368.  
  3369.                 -- initialize CURSOR to the first item (if any) of the
  3370.                 -- list currently built
  3371.                 CURSOR := TABLE (I).TABLE_DEFINITION.ENUM_TYPES (INDEX2 (I));
  3372.         PREVIOUS_CURSOR := null;
  3373.  
  3374.                 -- move in the list until the searched position is found
  3375.                 -- (ENUM_VALUE = 0) or the list is not yet long enough
  3376.                 -- (CURSOR = null)
  3377.                 while ENUM_VALUE /= 0 and CURSOR /= null loop
  3378.                     ENUM_VALUE := ENUM_VALUE - 1;
  3379.             PREVIOUS_CURSOR := CURSOR;
  3380.                     CURSOR := CURSOR.all.OTHER;
  3381.                 end loop;
  3382.  
  3383.                 -- append empty items to the list until the list is long 
  3384.                 -- enough
  3385.                 while ENUM_VALUE /= 0 loop
  3386.                     ENUM_VALUE := ENUM_VALUE - 1;
  3387.                     CURSOR := new ENUM_ITEM;
  3388.             PREVIOUS_CURSOR := CURSOR;
  3389.                     CURSOR := CURSOR.all.OTHER;
  3390.                 end loop;
  3391.  
  3392.                 if CURSOR = null then
  3393.           CURSOR := new ENUM_ITEM;
  3394.           if PREVIOUS_CURSOR = null then
  3395.             TABLE (I).TABLE_DEFINITION.ENUM_TYPES (INDEX2 (I))
  3396.             := CURSOR;
  3397.           else
  3398.                     PREVIOUS_CURSOR.all.OTHER := CURSOR;
  3399.           end if;
  3400.                 end if;
  3401.  
  3402.                 -- store the image of the item into the found element
  3403.                 -- of the list
  3404.                 CURSOR.all.ENUM_IMAGE := IMAGE_STRING;
  3405.  
  3406.                 if INDEX2 (I) = INDEX1 (I) + 1 then
  3407.                     TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (INDEX2 (I)) :=
  3408.                       COLNAME;
  3409.                     INDEX1 (I) := INDEX2 (I);
  3410.                 end if;
  3411.             end loop;
  3412.         end loop;
  3413.         ADA_TABLES.CLOSE_ADA_TABLE;
  3414.  
  3415.         -- unlock the three reserved tables
  3416.         ADA_TABLES.UNLOCK_ADA_TABLES;
  3417. ---------------------get the basical definitions of the tables------------
  3418.  
  3419.         -- actually set the requested locks
  3420.         for I in 1 .. TABLE_NUMBER loop
  3421.             RELIST (12 * I - 11 .. 12 * I) := TABLE_NAME2 (I) & "  ";
  3422.         end loop;
  3423.  
  3424.         for I in 1 .. TABLE_NUMBER loop
  3425.             if LOCK_LIST (LOCK_LIST'FIRST - 1 + I).ACCESS_MODE = SHARED then
  3426.                 MODLIS (I) := 0;
  3427.             else
  3428.                 MODLIS (I) := 1;
  3429.             end if;
  3430.         end loop;
  3431.  
  3432.         F77_CALLABLES.ADA_DLOCK (RELIST, MODLIS, TABLE_NUMBER, RTN);
  3433.  
  3434.         if RTN /= 0 then
  3435.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3436.             "One of the tables to be locked does not exist, is not on line,");
  3437.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3438.             "or can not be accessed");
  3439.             raise X_CANT_ACCESS_TABLE;
  3440.         end if;
  3441.  
  3442.         for I in 1 .. TABLE_NUMBER loop
  3443.             -- for each table to be locked
  3444.  
  3445.             -- first open it
  3446.             F77_CALLABLES.ADA_OPENR (TABLE_NAME2 (I), DESCR, RTN);
  3447.  
  3448.             if RTN /= 0 then
  3449. -- the table could not be opened;
  3450. -- all that have already been locked and opened must then
  3451. -- be closed and unlocked
  3452.  
  3453.                 for II in 1 .. TABLE_NUMBER loop
  3454.                     TABLE (II).TABLE_STATUS.TABLE_IS_LOCKED := FALSE;
  3455.                 end loop;
  3456.  
  3457.                 for II in 1 .. I - 1 loop
  3458.                     F77_CALLABLES.ADA_CLOSER (TABLE (II).TABLE_STATUS.DESCR);
  3459.                 end loop;
  3460.  
  3461.                 F77_CALLABLES.ADA_DUNLK;
  3462.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3463.             "One of the tables to be locked does not exist, is not on line,");
  3464.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3465.             "or can not be accessed");
  3466.                 raise X_CANT_ACCESS_TABLE;
  3467.             end if;
  3468.  
  3469.             -- store the table name into TABLE
  3470.             TABLE (I).NAME := TABLE_NAME2 (I);
  3471.             -- initialize the table status
  3472.             TABLE (I).TABLE_STATUS :=
  3473.               (TABLE_IS_LOCKED     => TRUE,
  3474.                CURRENT_LOCK        =>
  3475.                  LOCK_LIST (LOCK_LIST'FIRST + I - 1).ACCESS_MODE,
  3476.                DESCR               => DESCR,
  3477.                FIND_STATUS         => DEAD,
  3478.                SELECTION_CRITERION => null,
  3479.                CURRENT_ROW         => (-1, 0, 0));
  3480.  
  3481.             -- initialize actual current row to the beginning of the table
  3482.             F77_CALLABLES.ADA_SETGET (DESCR, 3, TIDD, TIDD, RTN);
  3483.             if RTN /= 0 then
  3484.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3485.                 "internal error during initializing the current row");
  3486.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3487.                 "of a table to be locked");
  3488.                 raise X_INTERNAL_ERROR;
  3489.             end if;
  3490.  
  3491.             -- get the scalar columns number, names, order, types and
  3492.             -- lengths
  3493.             ATTL := -1;
  3494.             ATNAM := (others => ' ');
  3495.             F77_CALLABLES.ADA_DGINFO
  3496.                (DESCR, ATNAM, ATTL, ATIDX, ATLEN, ATTYP, RTN);
  3497.             if RTN /= 0 then
  3498.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3499.                 "internal error during reading the description of a table");
  3500.                 raise X_INTERNAL_ERROR;
  3501.             end if;
  3502.             TABLE (I).TABLE_DEFINITION.COLUMN_NUMBER := ATTL;
  3503.  
  3504.             -- get the sort information
  3505.             F77_CALLABLES.ADA_FACSS (DESCR, ACSIFO);
  3506.             -- store it into TABLE
  3507.             if ACSIFO (1) = 1 then
  3508.                 TABLE (I).TABLE_DEFINITION.SORTED := FALSE;
  3509.             else
  3510.                 TABLE (I).TABLE_DEFINITION.SORTED := TRUE;
  3511.             end if;
  3512.  
  3513.             for II in 1 .. ATTL loop
  3514.                 -- for each scalar column
  3515.  
  3516.                 -- store the column names into the COLNAME variable
  3517.                 COLNAME := UTILITIES.NORMALIZE
  3518.                         (ATNAM (1 + (II - 1) * 12 .. II * 12 - 2));
  3519.  
  3520.                 -- look for COLNAME among already defined columns
  3521.                 for III in II .. II + INDEX1 (I) loop
  3522.                     INDEX := III;
  3523.                     exit when III = COL_NO + 1;
  3524.                     exit when TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (III) =
  3525.                               COLNAME;
  3526.                 end loop;
  3527.  
  3528.                 if TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (INDEX) =
  3529.                    COLNAME then
  3530.                     -- this column has already been defined
  3531.                     if II /= INDEX then
  3532.                         TABLE (I).TABLE_DEFINITION.CONSTRAINTS (II) :=
  3533.                           TABLE (I).TABLE_DEFINITION.CONSTRAINTS (INDEX);
  3534.                         TABLE (I).TABLE_DEFINITION.IN_RECORD (II) :=
  3535.                           TABLE (I).TABLE_DEFINITION.IN_RECORD (INDEX);
  3536.                         TABLE (I).TABLE_DEFINITION.ENUM_TYPES (II) :=
  3537.                           TABLE (I).TABLE_DEFINITION.ENUM_TYPES (INDEX);
  3538.     
  3539.                         TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (INDEX) :=
  3540.                           (1 .. NAME_LENGTH => ' ');
  3541.                         TABLE (I).TABLE_DEFINITION.CONSTRAINTS (INDEX) :=
  3542.                             null;
  3543.                         TABLE (I).TABLE_DEFINITION.IN_RECORD (INDEX) :=
  3544.                             (1 .. NAME_LENGTH => ' ');
  3545.                         TABLE (I).TABLE_DEFINITION.ENUM_TYPES (INDEX) :=
  3546.                             null;
  3547.                     end if;
  3548.  
  3549.                 else
  3550. -- this column has not yet been defined
  3551.  
  3552. -- look at the first free place
  3553.                     for III in II + 1 .. II + INDEX1 (I) + 1 loop
  3554.                         INDEX := III;
  3555.                         exit when TABLE (I).TABLE_DEFINITION.COLUMN_NAMES
  3556.                                      (III) = (1 .. NAME_LENGTH => ' ');
  3557.                     end loop;
  3558.  
  3559.                     -- save into this free place the row definition 
  3560.                     -- which was previously where the new row definition
  3561.                     -- is to be inserted
  3562.                     if II /= INDEX then
  3563.                         TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (INDEX) :=
  3564.                           TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (II);
  3565.                         TABLE (I).TABLE_DEFINITION.CONSTRAINTS (INDEX) :=
  3566.                           TABLE (I).TABLE_DEFINITION.CONSTRAINTS (II);
  3567.                         TABLE (I).TABLE_DEFINITION.IN_RECORD (INDEX) :=
  3568.                           TABLE (I).TABLE_DEFINITION.IN_RECORD (II);
  3569.                         TABLE (I).TABLE_DEFINITION.ENUM_TYPES (INDEX) :=
  3570.                           TABLE (I).TABLE_DEFINITION.ENUM_TYPES (II);
  3571.     
  3572.                         TABLE (I).TABLE_DEFINITION.CONSTRAINTS (II) :=
  3573.                             null;
  3574.                         TABLE (I).TABLE_DEFINITION.IN_RECORD (II) :=
  3575.                             (1 .. NAME_LENGTH => ' ');
  3576.                         TABLE (I).TABLE_DEFINITION.ENUM_TYPES (II) :=
  3577.                             null;
  3578.                     end if;
  3579.                 end if;
  3580.  
  3581.                 -- store the column name into TABLE
  3582.                 TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (II) := COLNAME;
  3583.             end loop;
  3584.  
  3585.             -- store the index, type and length of the column into TABLE
  3586.             TABLE (I).TABLE_DEFINITION.COLUMN_INDEX := ATIDX;
  3587.             TABLE (I).TABLE_DEFINITION.COLUMN_TYPES := ATTYP;
  3588.             TABLE (I).TABLE_DEFINITION.COLUMN_LENGTH := ATLEN;
  3589.         end loop;
  3590.     end LOCK;
  3591.  
  3592.     procedure GET_INFORMATION (TABLE_NAME    : STRING;
  3593.                                COLUMN_NUMBER : out POSITIVE;
  3594.                                COLUMN_LIST   : out STRING) is
  3595. --************************************************************************
  3596. --**                                                                    **
  3597. --**   UNIT NAME :          GET_INFORMATION                             **
  3598. --**   ~~~~~~~~~~~                                                      **
  3599. --** DESCRIPTION--------------------------------------------------------**
  3600. --**                                                                    **
  3601. --**                                                                    **
  3602. --**    if not A_DATABASE_IS_OPEN then                                  **
  3603. --**        raise X_NO_OPEN_DB;                                         **
  3604. --**    end if;                                                         **
  3605. --**                                                                    **
  3606. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  3607. --**            -- this information can be read  in the LOCK attribute  **
  3608. --**            -- of the TABLE array of the STATUS package             **
  3609. --**                                                                    **
  3610. --**        raise X_TABLE_NOT_LOCKED;                                   **
  3611. --**    end if;                                                         **
  3612. --**                                                                    **
  3613. --**    TRANSLATE_INFORMATION_INTO_THE_OUTPUT_FORMAT;                   **
  3614. --**        -- generates from the information got from the database  a  **
  3615. --**        -- sentence of the language recognized by the DEFINE_TABLE  **
  3616. --**        -- procedure.                                               **
  3617. --**                                                                    **
  3618. --**    if COLUMN_LIST_IS_TOO_SHORT then                                **
  3619. --**        raise X_TOO_SHORT_STRING;                                   **
  3620. --**    end if;                                                         **
  3621. --**                                                                    **
  3622. --** INPUT--------------------------------------------------------------**
  3623. --**                                                                    **
  3624. --**  TABLE_NAME is the name of the table the user wants  information   **
  3625. --**  about.                                                            **
  3626. --**                                                                    **
  3627. --** STATUS VARIABLES USED----------------------------------------------**
  3628. --**                                                                    **
  3629. --**    A_DATABASE_IS_OPEN                                              **
  3630. --**    TABLE.LOCK                                                      **
  3631. --**                                                                    **
  3632. --** OUTPUT-------------------------------------------------------------**
  3633. --**                                                                    **
  3634. --**  COLUMN_NUMBER  is  the  number of columns  the  table  contains.  **
  3635. --**                                                                    **
  3636. --**  COLUMN_LIST is the list of the column definitions of the  table,  **
  3637. --**  in   the   same   format    as   in  the  DEFINE_TABLE   format.  **
  3638. --**                                                                    **
  3639. --** STATUS VARIABLES UPDATED-------------------------------------------**
  3640. --**                                                                    **
  3641. --**                                                                    **
  3642. --** EXCEPTIONS---------------------------------------------------------**
  3643. --**                                                                    **
  3644. --**    X_NO_OPEN_DB                                                    **
  3645. --**    X_TABLE_NOT_LOCKED                                              **
  3646. --**    X_TOO_SHORT_STRING                                              **
  3647. --**                                                                    **
  3648. --************************************************************************
  3649.         IC, IT, INDEX : INTEGER;
  3650.         STRING_SIZE   : INTEGER := COLUMN_LIST'LENGTH;
  3651.  
  3652.         procedure ASSIGN_TO_COLUMN_LIST (S : STRING) is
  3653.  
  3654.                 -- ASSIGN_TO_COLUMN_LIST appends S to COLUMN_LIST at the
  3655.                 -- current position defined by INDEX, and updates INDEX, or
  3656.                 -- raises X_TOO_SHORT_STRING if COLUMN_LIST is not long enough
  3657.  
  3658.             S_LENGTH : INTEGER := S'LENGTH;
  3659.         begin
  3660.             if INDEX + S_LENGTH - 1 > STRING_SIZE then
  3661.                 raise X_TOO_SHORT_STRING;
  3662.             else
  3663.                 COLUMN_LIST (INDEX .. INDEX + S_LENGTH - 1) := S;
  3664.                 INDEX := INDEX + S_LENGTH;
  3665.             end if;
  3666.         end ASSIGN_TO_COLUMN_LIST;
  3667.  
  3668.         function ENUM_IMAGE (CURRENT_IMAGE : ENUM_ITEM_ACCESS)
  3669.                               return ENUM_ITEM_ACCESS is
  3670.  
  3671.                 -- write into COLUMN_LIST the image of the enumeration
  3672.                 -- item defined by CURRENT_IMAGE, and return a pointer
  3673.                 -- to the following item
  3674.  
  3675.             MEANINGFUL : INTEGER;
  3676.         begin
  3677.                 -- MEANINGFUL will be set to the number of the last
  3678.                 -- non-blank character of the enumeration item
  3679.             MEANINGFUL := IMAGE_SZ;
  3680.  
  3681.             while CURRENT_IMAGE.ENUM_IMAGE (MEANINGFUL) = ' ' loop
  3682.                 MEANINGFUL := MEANINGFUL - 1;
  3683.             end loop;
  3684.  
  3685.                 -- copy the image into COLUMN_LIST
  3686.             ASSIGN_TO_COLUMN_LIST (CURRENT_IMAGE.ENUM_IMAGE (1 .. MEANINGFUL));
  3687.  
  3688.                 -- and return the pointer to the next item
  3689.             return CURRENT_IMAGE.OTHER;
  3690.         end ENUM_IMAGE;
  3691.  
  3692.         procedure CONSTRAINT is
  3693.  
  3694.                 -- write into COLUMN_LIST a range constraint declaration
  3695.  
  3696.             MEANINGFUL : INTEGER;
  3697.         begin
  3698.                 -- first check if there is one
  3699.             if TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC) /= null then
  3700.                     -- there is one
  3701.  
  3702.                         -- write " range"
  3703.                 ASSIGN_TO_COLUMN_LIST (" range ");
  3704.  
  3705.                         -- copy the minimum value
  3706.                 MEANINGFUL := RANGE_SIZE;
  3707.                 while TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC).all
  3708.                          (MEANINGFUL) = ' ' loop
  3709.                     MEANINGFUL := MEANINGFUL - 1;
  3710.                 end loop;
  3711.                 ASSIGN_TO_COLUMN_LIST (TABLE (IT).TABLE_DEFINITION.CONSTRAINTS
  3712.                     (IC).all (1 .. MEANINGFUL) & " .. ");
  3713.  
  3714.                         -- copy the maximum value
  3715.                 MEANINGFUL := 2 * RANGE_SIZE;
  3716.                 while TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC).all
  3717.                          (MEANINGFUL) = ' ' loop
  3718.                     MEANINGFUL := MEANINGFUL - 1;
  3719.                 end loop;
  3720.                 ASSIGN_TO_COLUMN_LIST (TABLE(IT).TABLE_DEFINITION.CONSTRAINTS
  3721.                     (IC).all (RANGE_SIZE + 1 .. MEANINGFUL));
  3722.             end if;
  3723.         end CONSTRAINT;
  3724.  
  3725.         procedure SCALAR_DESCR is
  3726.  
  3727.                 -- write into COLUMN_LIST a scalar column declaration
  3728.                 -- (i.e. type, length, constraint)
  3729.  
  3730.             INTEGER_IMAGE        : STRING (1 .. 10);
  3731.             INTEGER_IMAGE_LENGTH : INTEGER;
  3732.             NEXT_IMAGE           : ENUM_ITEM_ACCESS;
  3733.         begin
  3734.             if TABLE (IT).TABLE_DEFINITION.COLUMN_TYPES (IC) = 1 then
  3735.                         -- INTEGER type column
  3736.  
  3737.                 ASSIGN_TO_COLUMN_LIST ("integer");
  3738.                 CONSTRAINT;
  3739.  
  3740.             elsif TABLE (IT).TABLE_DEFINITION.COLUMN_TYPES (IC) = 2 then
  3741.                         -- FLOAT type column
  3742.  
  3743.                 ASSIGN_TO_COLUMN_LIST ("float");
  3744.                 CONSTRAINT;
  3745.  
  3746.             elsif TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC) /= null then
  3747.                         -- ENUMERATION type column
  3748.  
  3749.                 ASSIGN_TO_COLUMN_LIST ("(");
  3750.                 NEXT_IMAGE := ENUM_IMAGE
  3751.                                  (TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC));
  3752.  
  3753.                 while NEXT_IMAGE /= null loop
  3754.                     ASSIGN_TO_COLUMN_LIST (",");
  3755.                     NEXT_IMAGE := ENUM_IMAGE (NEXT_IMAGE);
  3756.                 end loop;
  3757.  
  3758.                 ASSIGN_TO_COLUMN_LIST (")");
  3759.                 INDEX := INDEX + 1;
  3760.                 CONSTRAINT;
  3761.  
  3762.             else
  3763.                         -- STRING type column
  3764.  
  3765.                 ASSIGN_TO_COLUMN_LIST ("string(1..");
  3766.                 INTEGER_IMAGE_LENGTH :=
  3767.                   INTEGER'IMAGE (TABLE (IT).TABLE_DEFINITION.COLUMN_LENGTH (IC))
  3768.                    'LENGTH;
  3769.                 INTEGER_IMAGE (1 .. INTEGER_IMAGE_LENGTH) :=
  3770.                   INTEGER'IMAGE
  3771.                     (TABLE (IT).TABLE_DEFINITION.COLUMN_LENGTH (IC));
  3772.                 ASSIGN_TO_COLUMN_LIST
  3773.                     (INTEGER_IMAGE (1 .. INTEGER_IMAGE_LENGTH) & ")");
  3774.             end if;
  3775.         end SCALAR_DESCR;
  3776.  
  3777.         procedure COLUMN_DESCR is
  3778.  
  3779.                 -- write into COLUMN_LIST a column declaration; such
  3780.                 -- a column can either be a record column or a scalar
  3781.                 -- column, but not only a component column of an
  3782.                 -- encapsulating record one.
  3783.  
  3784.             RECORD_NAME : STRING (1 .. NAME_LENGTH);
  3785.         begin
  3786.             RECORD_NAME := TABLE (IT).TABLE_DEFINITION.IN_RECORD (IC);
  3787.  
  3788.             if RECORD_NAME = (1 .. NAME_LENGTH => ' ') then
  3789.                         -- the current column is a scalar column
  3790.  
  3791.                 ASSIGN_TO_COLUMN_LIST
  3792.                  (TABLE (IT).TABLE_DEFINITION.COLUMN_NAMES (IC) & " ");
  3793.                 SCALAR_DESCR;
  3794.                 IC := IC + 1;
  3795.             else
  3796.                         -- the current column is a record column
  3797.  
  3798.                         -- first write the declaration of the first
  3799.                         -- component
  3800.                 ASSIGN_TO_COLUMN_LIST (RECORD_NAME & " ");
  3801.                 ASSIGN_TO_COLUMN_LIST 
  3802.                     (TABLE (IT).TABLE_DEFINITION.COLUMN_NAMES (IC) & " ");
  3803.                 SCALAR_DESCR;
  3804.                 IC := IC + 1;
  3805.  
  3806.                         -- then write the declaration of the following
  3807.                         -- components, if any
  3808.                 while TABLE (IT).TABLE_DEFINITION.IN_RECORD (IC) =
  3809.                       RECORD_NAME loop
  3810.                     ASSIGN_TO_COLUMN_LIST
  3811.                      ("," & TABLE (IT).TABLE_DEFINITION.COLUMN_NAMES (IC));
  3812.                     SCALAR_DESCR;
  3813.                     IC := IC + 1;
  3814.                 end loop;
  3815.             end if;
  3816.         end COLUMN_DESCR;
  3817.  
  3818.     begin
  3819.         if not SHARE.A_DATABASE_IS_OPEN then
  3820.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3821.             "A database must be opened before trying to get the description");
  3822.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3823.             "of an included table");
  3824.             raise X_NO_OPEN_DB;
  3825.         end if;
  3826.  
  3827.                 -- store in IT the identifier of the TABLE_NAME table,
  3828.                 -- or raise X_TABLE_NOT_LOCKED if this name is unknown
  3829.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  3830.  
  3831.                 -- return COLUMN_NUMBER
  3832.         COLUMN_NUMBER := TABLE (IT).TABLE_DEFINITION.COLUMN_NUMBER;
  3833.  
  3834.                 -- INDEX will be an index to the next character to be
  3835.                 -- written into COLUMN_LIST
  3836.         INDEX := 1;
  3837.                 -- IC will be the identifier of the currently processed
  3838.                 -- scalar column
  3839.         IC := 1;
  3840.  
  3841.                 -- first write the first column declaration
  3842.         COLUMN_DESCR;
  3843.  
  3844.         while IC /= TABLE (IT).TABLE_DEFINITION.COLUMN_NUMBER + 1 loop
  3845.                 -- loop for each column declaration
  3846.  
  3847.             ASSIGN_TO_COLUMN_LIST (";");
  3848.             COLUMN_DESCR;
  3849.         end loop;
  3850.  
  3851.         COLUMN_LIST (INDEX .. STRING_SIZE) := (INDEX .. STRING_SIZE => ' ');
  3852.     end GET_INFORMATION;
  3853.  
  3854.  
  3855.     procedure UNLOCK is
  3856. --************************************************************************
  3857. --**                                                                    **
  3858. --**   UNIT NAME :          UNLOCK                                      **
  3859. --**   ~~~~~~~~~~~                                                      **
  3860. --** DESCRIPTION--------------------------------------------------------**
  3861. --**                                                                    **
  3862. --**    if not A_DATABASE_IS_OPEN then                                  **
  3863. --**        raise X_NO_OPEN_DB;                                         **
  3864. --**    end if;                                                         **
  3865. --**                                                                    **
  3866. --**    for TABLE_NAME in TABLE'FIRST .. TABLE'LAST loop                **
  3867. --**                                                                    **
  3868. --**            -- for each known table, look for its current lock      **
  3869. --**            -- (unlocked, shared, or exclusive)                     **
  3870. --**                                                                    **
  3871. --**        if TABLE_NAME_IS_LOCKED then                                **
  3872. --**                                                                    **
  3873. --**                -- the LOCK component of TABLE_NAME in the TABLE    **
  3874. --**                -- status array is 'shared' or 'exclusive' but not  **
  3875. --**                -- 'unlocked'                                       **
  3876. --**                                                                    **
  3877. --**            CLOSE_TABLE (TABLE_NAME);                               **
  3878. --**            TABLE(TABLE_NAME).LOCK := UNLOCKED;                     **
  3879. --**        end if;                                                     **
  3880. --**    end loop;                                                       **
  3881. --**                                                                    **
  3882. --**    UNLOCK_TABLES;                                                  **
  3883. --**                                                                    **
  3884. --**                                                                    **
  3885. --** INPUT--------------------------------------------------------------**
  3886. --**                                                                    **
  3887. --**                                                                    **
  3888. --** STATUS VARIABLES USED----------------------------------------------**
  3889. --**                                                                    **
  3890. --**    A_DATABASE_IS_OPEN                                              **
  3891. --**    TABLE.LOCK                                                      **
  3892. --**                                                                    **
  3893. --** OUTPUT-------------------------------------------------------------**
  3894. --**                                                                    **
  3895. --**                                                                    **
  3896. --** STATUS VARIABLES UPDATED-------------------------------------------**
  3897. --**                                                                    **
  3898. --**    TABLE.LOCK                                                      **
  3899. --**                                                                    **
  3900. --** EXCEPTIONS---------------------------------------------------------**
  3901. --**                                                                    **
  3902. --**    X_NO_OPEN_DB                                                    **
  3903. --**                                                                    **
  3904. --************************************************************************
  3905.     begin
  3906.         if not SHARE.A_DATABASE_IS_OPEN then
  3907.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  3908.             "UNLOCK is available with an open database only");
  3909.             raise X_NO_OPEN_DB;
  3910.         end if;
  3911.  
  3912.         for I in 1 .. TABLE_NO loop
  3913.             if TABLE (I).TABLE_STATUS.TABLE_IS_LOCKED then
  3914.                 F77_CALLABLES.ADA_CLOSER (TABLE (I).TABLE_STATUS.DESCR);
  3915.                 TABLE (I).TABLE_STATUS.TABLE_IS_LOCKED := FALSE;
  3916.             end if;
  3917.         end loop;
  3918.  
  3919.         F77_CALLABLES.ADA_DUNLK;
  3920.     end UNLOCK;
  3921.  
  3922.     procedure CLOSE is
  3923. --************************************************************************
  3924. --**                                                                    **
  3925. --**   UNIT NAME :          CLOSE                                       **
  3926. --**   ~~~~~~~~~~~                                                      **
  3927. --** DESCRIPTION--------------------------------------------------------**
  3928. --**                                                                    **
  3929. --**                                                                    **
  3930. --**    LL_DAMES.UNLOCK;                                                **
  3931. --**        -- unlock locked tables, if any                             **
  3932. --**                                                                    **
  3933. --**    CLOSE_DATABASE;                                                 **
  3934. --**        -- close the database;                                      **
  3935. --**                                                                    **
  3936. --**    A_DATABASE_IS_OPEN := FALSE;                                    **
  3937. --**                                                                    **
  3938. --**                                                                    **
  3939. --** INPUT--------------------------------------------------------------**
  3940. --**                                                                    **
  3941. --**                                                                    **
  3942. --** STATUS VARIABLES USED----------------------------------------------**
  3943. --**                                                                    **
  3944. --**    A_DATABASE_IS_OPEN                                              **
  3945. --**                                                                    **
  3946. --** OUTPUT-------------------------------------------------------------**
  3947. --**                                                                    **
  3948. --**                                                                    **
  3949. --** STATUS VARIABLES UPDATED-------------------------------------------**
  3950. --**                                                                    **
  3951. --**    A_DATABASE_IS_OPEN                                              **
  3952. --**    TABLE.LOCK                                                      **
  3953. --**                                                                    **
  3954. --** EXCEPTIONS---------------------------------------------------------**
  3955. --**                                                                    **
  3956. --**    X_NO_OPEN_DB                                                    **
  3957. --**                                                                    **
  3958. --************************************************************************
  3959.     begin
  3960.         UNLOCK;
  3961.         F77_CALLABLES.ADA_CLOSDB;
  3962.         SHARE.A_DATABASE_IS_OPEN := FALSE;
  3963.     end CLOSE;
  3964.  
  3965.  
  3966.     procedure MATCH (TABLE_NAME   : STRING;
  3967.                      COLUMN_NAME  : STRING;
  3968.                      KEY_MATCH    : KEY_MATCH_TYPE;
  3969.                      COLUMN_VALUE : USER_COLUMN) is
  3970. --************************************************************************
  3971. --**                                                                    **
  3972. --**   UNIT NAME :          MATCH                                       **
  3973. --**   ~~~~~~~~~~~                                                      **
  3974. --** DESCRIPTION--------------------------------------------------------**
  3975. --**                                                                    **
  3976. --**    if not A_DATABASE_IS_OPEN then                                  **
  3977. --**        raise X_TABLE_NOT_LOCKED;                                   **
  3978. --**    end if;                                                         **
  3979. --**                                                                    **
  3980. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  3981. --**            -- i.e. the LOCK component of TABLE_NAME in the TABLE   **
  3982. --**            -- status array is 'unlocked'                           **
  3983. --**        raise X_TABLE_NOT_LOCKED;                                   **
  3984. --**    end if;                                                         **
  3985. --**                                                                    **
  3986. --**    if COLUMN_NAME_DOES_NOT_EXIST then                              **
  3987. --**            -- COLUMN_NAME is not the name of one of the columns    **
  3988. --**            -- of the TABLE_NAME table, or is a record column.      **
  3989. --**        raise X_INVALID_COLUMN;                                     **
  3990. --**    end if;                                                         **
  3991. --**                                                                    **
  3992. --**    if COLUMN_TYPE_DOES_NOT_MATCH_INSTANTIATION_TYPE then           **
  3993. --**            -- information known by DAMES about the type of the     **
  3994. --**            -- COLUMN_NAME column does not match the USER_COLUMN    **
  3995. --**            -- type, which is defined when instantiating the        **
  3996. --**            -- generic DAMES_FIND package                           **
  3997. --**        raise X_INVALID_COLUMN;                                     **
  3998. --**    end if;                                                         **
  3999. --**                                                                    **
  4000. --**    if COLUMN_TYPE_DOES_NOT_MATCH_COLUMN_VALUE then                 **
  4001. --**            -- the type USER_COLUMN is then correct, but the value  **
  4002. --**            -- of the COLUMN_VALUE actual argument is not valid for **
  4003. --**            -- the COLUMN_NAME column type                          **
  4004. --**        raise X_INVALID_VALUE;                                      **
  4005. --**    end if;                                                         **
  4006. --**                                                                    **
  4007. --**    INITIALIZE_SELECTION_CRITERION (COLUMN_NAME,                    **
  4008. --**                                    KEY_MATCH,                      **
  4009. --**                                    COLUMN_VALUE);                  **
  4010. --**        -- build a new selection criterion, the first basic         **
  4011. --**        -- expression of which being :                              **
  4012. --**        --         'COLUMN_NAME KEY_MATCH COLUMN_VALUE'             **
  4013. --**        -- This criterion is specific to the TABLE_NAME table       **
  4014. --**                                                                    **
  4015. --**    UPDATE_FIND_STATUS;                                             **
  4016. --**        -- set  to  'CRITERION'  the  FIND_STATUS  component  of    **
  4017. --**        -- TABLE_NAME in the TABLE status array                     **
  4018. --**                                                                    **
  4019. --** INPUT--------------------------------------------------------------**
  4020. --**                                                                    **
  4021. --**  TABLE_NAME  is  the  name  of  the table on which the  selection  **
  4022. --**  criterion will be applied.                                        **
  4023. --**                                                                    **
  4024. --**  COLUMN_NAME is the name of the column to be used.                 **
  4025. --**                                                                    **
  4026. --**  KEY_MATCH is the match to be performed between the column of the  **
  4027. --**  candidate row and COLUMN_VALUE.                                   **
  4028. --**                                                                    **
  4029. --**  COLUMN_VALUE is the value to  be  compared  with the COLUMN_NAME  **
  4030. --**  column.                                                           **
  4031. --**                                                                    **
  4032. --** STATUS VARIABLES USED----------------------------------------------**
  4033. --**                                                                    **
  4034. --**    A_DATABASE_IS_OPEN                                              **
  4035. --**    TABLE.LOCK                                                      **
  4036. --**                                                                    **
  4037. --** OUTPUT-------------------------------------------------------------**
  4038. --**                                                                    **
  4039. --**                                                                    **
  4040. --** STATUS VARIABLES UPDATED-------------------------------------------**
  4041. --**                                                                    **
  4042. --**    TABLE.FIND_STATUS                                               **
  4043. --**    TABLE.SELECTION_CRITERION                                       **
  4044. --**                                                                    **
  4045. --** EXCEPTIONS---------------------------------------------------------**
  4046. --**                                                                    **
  4047. --**    X_INVALID_VALUE                                                 **
  4048. --**    X_INVALID_COLUMN                                                **
  4049. --**    X_TABLE_NOT_LOCKED                                              **
  4050. --**                                                                    **
  4051. --************************************************************************
  4052.         IT, IC     : INTEGER;
  4053.         MEANINGFUL : NATURAL;
  4054.         TRANSLATE  : INTEGER_ARRAY_TYPE (1 .. (MAX_STRING + 3) / 4) :=
  4055.                                 (others => 0);
  4056.         subtype NULL_STRING  is STRING (2 .. 1);
  4057.         subtype TRANSIT_TYPE is STRING
  4058.                                   (1 .. (USER_COLUMN'SIZE -
  4059.                                          NULL_STRING'SIZE) / CHARACTER'SIZE);
  4060.  
  4061.         TRANSIT : TRANSIT_TYPE;
  4062.  
  4063.         function USER_COLUMN_TO_INTEGER is new UNCHECKED_CONVERSION
  4064.                    (USER_COLUMN, INTEGER);
  4065.         function USER_COLUMN_TO_INTEGER16 is new UNCHECKED_CONVERSION
  4066.                    (USER_COLUMN, INTEGER16);
  4067.         function USER_COLUMN_TO_TRANSIT is new UNCHECKED_CONVERSION
  4068.                    (USER_COLUMN, TRANSIT_TYPE);
  4069.     begin
  4070.         if not SHARE.A_DATABASE_IS_OPEN then
  4071.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4072.             "A database must be opened and a table locked to use MATCH");
  4073.             raise X_TABLE_NOT_LOCKED;
  4074.         end if;
  4075.  
  4076.         -- get the table index or raise X_TABLE_NOT_LOCKED if this one
  4077.         -- does not exist
  4078.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  4079.  
  4080.         -- get the column index or raise X_INVALID_COLUMN if this one 
  4081.         -- does not exist
  4082.         IC := UTILITIES.SCALAR_COLUMN_ID (IT, COLUMN_NAME);
  4083.  
  4084.         -- check the user-defined type size
  4085.         if COLUMN_VALUE'SIZE /= UTILITIES.BIT_SIZE (IT, IC) then
  4086.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4087.             "The size of the Ada type used to instantiate MATCH");
  4088.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4089.             "does not correspond to the size of the " & COLUMN_NAME &
  4090.             " column");
  4091.             raise X_INVALID_COLUMN;
  4092.         end if;
  4093.  
  4094.         -- store into TRANSLATE the value to be compared with actual
  4095.         -- values of the candidate rows, and store into MEANINGFUL
  4096.         -- the number of meaningful components of TRANSLATE
  4097.         case TABLE (IT).TABLE_DEFINITION.COLUMN_TYPES (IC) is
  4098.             when 1 | 2 => 
  4099.                 -- INTEGER or FLOAT type
  4100.  
  4101.                 TRANSLATE (1) := USER_COLUMN_TO_INTEGER (COLUMN_VALUE);
  4102.                 MEANINGFUL := 1;
  4103.  
  4104.             when 5 => 
  4105.                 if TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC) /= null then
  4106.                     -- enumeration type
  4107.  
  4108.                     TRANSLATE (1) := INTEGER (USER_COLUMN_TO_INTEGER16
  4109.                                                         (COLUMN_VALUE));
  4110.                     MEANINGFUL := 1;
  4111.                 else
  4112.  
  4113.                     -- STRING type
  4114.                     TRANSIT := USER_COLUMN_TO_TRANSIT (COLUMN_VALUE);
  4115.                     MEANINGFUL := (TRANSIT'LENGTH + 3) / 4;
  4116.                     TRANSLATE (1 .. MEANINGFUL) :=
  4117.                       CONVERSION.F77_STRING (TRANSIT);
  4118.                 end if;
  4119.  
  4120.             when others =>
  4121.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4122.                 "internal error when identifying the column type in MATCH");
  4123.                 raise X_INTERNAL_ERROR;
  4124.         end case;
  4125.  
  4126.         if TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC) /= null then
  4127.                 -- a range constraint applies to the column;the
  4128.                 -- value must be checked not to violate this range.
  4129.             UTILITIES.CHECK_VALUE (TRANSLATE (1), IT, IC);
  4130.         end if;
  4131.  
  4132.         -- free all nodes of the already allocated ones
  4133.         TABLE_DESCRIPTOR.FREE_NODES (IT);
  4134.  
  4135.         -- add a new node to the selection criterion
  4136.         TABLE (IT).TABLE_STATUS.SELECTION_CRITERION :=
  4137.                 TABLE_DESCRIPTOR.NEW_NODE;
  4138.         TABLE (IT).TABLE_STATUS.SELECTION_CRITERION.all :=
  4139.                    (COLUMN_ID                        => IC,
  4140.                     KEY_MATCH                        => KEY_MATCH,
  4141.                     COLUMN_VALUE                     => TRANSLATE,
  4142.                     MEANINGFUL                       => MEANINGFUL,
  4143.                     USER_OPERATOR | TREE_OPERATOR     => OR_OPERATOR,
  4144.                     FIRST_CHILD | SECOND_CHILD | OTHER => null);
  4145.  
  4146.         -- set the find-status to 'CRITERION'
  4147.         TABLE (IT).TABLE_STATUS.FIND_STATUS := CRITERION;
  4148.     end MATCH;
  4149.  
  4150.     procedure OR_MATCH (TABLE_NAME   : STRING;
  4151.                         COLUMN_NAME  : STRING;
  4152.                         KEY_MATCH    : KEY_MATCH_TYPE;
  4153.                         COLUMN_VALUE : USER_COLUMN) is
  4154. --************************************************************************
  4155. --**                                                                    **
  4156. --**   UNIT NAME :          OR_MATCH                                    **
  4157. --**   ~~~~~~~~~~~                                                      **
  4158. --** DESCRIPTION--------------------------------------------------------**
  4159. --**                                                                    **
  4160. --**    if not A_DATABASE_IS_OPEN then                                  **
  4161. --**        raise X_TABLE_NOT_LOCKED;                                   **
  4162. --**    end if;                                                         **
  4163. --**                                                                    **
  4164. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  4165. --**            -- i.e. the LOCK component of TABLE_NAME in the TABLE   **
  4166. --**            -- status array is 'unlocked'                           **
  4167. --**        raise X_TABLE_NOT_LOCKED;                                   **
  4168. --**    end if;                                                         **
  4169. --**                                                                    **
  4170. --**    if FIND_STATUS_IS_NOT_CRITERION then                            **
  4171. --**            -- the FIND_STATUS component of TABLE_NAME in the TABLE **
  4172. --**            -- status array is not 'criterion'                      **
  4173. --**        raise X_NO_PREVIOUS_MATCH;                                  **
  4174. --**    end if;                                                         **
  4175. --**                                                                    **
  4176. --**    if COLUMN_NAME_DOES_NOT_EXIST then                              **
  4177. --**            -- COLUMN_NAME is not the name of one of the columns    **
  4178. --**            -- of the TABLE_NAME table, or is a record column.      **
  4179. --**        raise X_INVALID_COLUMN;                                     **
  4180. --**    end if;                                                         **
  4181. --**                                                                    **
  4182. --**    if COLUMN_TYPE_DOES_NOT_MATCH_INSTANTIATION_TYPE then           **
  4183. --**            -- information known by DAMES about the type of the     **
  4184. --**            -- COLUMN_NAME column does not match the USER_COLUMN    **
  4185. --**            -- type, which is defined when instantiating the        **
  4186. --**            -- generic OR_MATCH procedure.                          **
  4187. --**        raise X_INVALID_COLUMN;                                     **
  4188. --**    end if;                                                         **
  4189. --**                                                                    **
  4190. --**    if COLUMN_TYPE_DOES_NOT_MATCH_COLUMN_VALUE then                 **
  4191. --**            -- the type USER_COLUMN is then correct, but the value  **
  4192. --**            -- of the COLUMN_VALUE actual argument is not valid for **
  4193. --**            -- the COLUMN_NAME column type                          **
  4194. --**        raise X_INVALID_VALUE;                                      **
  4195. --**    end if;                                                         **
  4196. --**                                                                    **
  4197. --**    APPEND_TO_SELECTION_CRITERION ( OR,                             **
  4198. --**                                    COLUMN_NAME,                    **
  4199. --**                                    KEY_MATCH,                      **
  4200. --**                                    COLUMN_VALUE);                  **
  4201. --**        -- add to the current selection criterion another basic     **
  4202. --**        -- expression, which is :                                   **
  4203. --**        --         'COLUMN_NAME KEY_MATCH COLUMN_VALUE'             **
  4204. --**        -- This new basic expression is connected to the already    **
  4205. --**        -- defined ones with the OR logical operator.               **
  4206. --**        -- This criterion is specific to the TABLE_NAME table       **
  4207. --**                                                                    **
  4208. --**                                                                    **
  4209. --** INPUT--------------------------------------------------------------**
  4210. --**                                                                    **
  4211. --**  TABLE_NAME  is  the  name  of  the table on which the  selection  **
  4212. --**  criterion will be applied.                                        **
  4213. --**                                                                    **
  4214. --**  COLUMN_NAME is the name of the column to be used.                 **
  4215. --**                                                                    **
  4216. --**  KEY_MATCH is the match to be performed between the column of the  **
  4217. --**  candidate row and COLUMN_VALUE.                                   **
  4218. --**                                                                    **
  4219. --**  COLUMN_VALUE is the value to  be  compared  with the COLUMN_NAME  **
  4220. --**  column.                                                           **
  4221. --**                                                                    **
  4222. --** STATUS VARIABLES USED----------------------------------------------**
  4223. --**                                                                    **
  4224. --**    A_DATABASE_IS_OPEN                                              **
  4225. --**    TABLE.LOCK                                                      **
  4226. --**    TABLE.FIND_STATUS                                               **
  4227. --**                                                                    **
  4228. --** OUTPUT-------------------------------------------------------------**
  4229. --**                                                                    **
  4230. --**                                                                    **
  4231. --** STATUS VARIABLES UPDATED-------------------------------------------**
  4232. --**                                                                    **
  4233. --**    TABLE.SELECTION_CRITERION                                       **
  4234. --**                                                                    **
  4235. --** EXCEPTIONS---------------------------------------------------------**
  4236. --**                                                                    **
  4237. --**    X_INVALID_VALUE                                                 **
  4238. --**    X_INVALID_COLUMN                                                **
  4239. --**    X_TABLE_NOT_LOCKED                                              **
  4240. --**    X_NO_PREVIOUS_MATCH                                             **
  4241. --**                                                                    **
  4242. --************************************************************************
  4243.         IT, IC     : INTEGER;
  4244.         MEANINGFUL : NATURAL;
  4245.         TRANSLATE  : INTEGER_ARRAY_TYPE (1 .. (MAX_STRING + 3) / 4);
  4246.         LAST_NODE  : NODE_ACCESS;
  4247.  
  4248.         subtype NULL_STRING  is STRING (2 .. 1);
  4249.         subtype TRANSIT_TYPE is STRING
  4250.                                   (1 .. (USER_COLUMN'SIZE -
  4251.                                          NULL_STRING'SIZE) / CHARACTER'SIZE);
  4252.  
  4253.         TRANSIT : TRANSIT_TYPE;
  4254.  
  4255.         function USER_COLUMN_TO_TRANSIT is new UNCHECKED_CONVERSION
  4256.                    (USER_COLUMN, TRANSIT_TYPE);
  4257.         function USER_COLUMN_TO_INTEGER is new UNCHECKED_CONVERSION
  4258.                    (USER_COLUMN, INTEGER);
  4259.         function USER_COLUMN_TO_INTEGER16 is new UNCHECKED_CONVERSION
  4260.                    (USER_COLUMN, INTEGER16);
  4261.  
  4262.     begin
  4263.         if not SHARE.A_DATABASE_IS_OPEN then
  4264.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4265.             "A database must be opened and a table locked to use OR_MATCH");
  4266.             raise X_TABLE_NOT_LOCKED;
  4267.         end if;
  4268.  
  4269.         -- get the table index or raise X_TABLE_NOT_LOCKED
  4270.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  4271.  
  4272.         if TABLE (IT).TABLE_STATUS.FIND_STATUS /= CRITERION then
  4273.             -- the find-status is not 'criterion'; it means that the
  4274.             -- MATCH procedure has not been previously called, or has been
  4275.             -- followed by a FIND call
  4276.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4277.             "MATCH must be called before calling OR_MATCH");
  4278.             raise X_NO_PREVIOUS_MATCH;
  4279.         end if;
  4280.  
  4281.         -- get the index corresponding to COLUMN_NAME, assuming that
  4282.         -- this is the name of a scalar column, otherwise raise
  4283.         -- X_INVALID_COLUMN
  4284.         IC := UTILITIES.SCALAR_COLUMN_ID (IT, COLUMN_NAME);
  4285.  
  4286.         if COLUMN_VALUE'SIZE /= UTILITIES.BIT_SIZE (IT, IC) then
  4287.             -- the actual parameter size does not match the required size
  4288.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4289.             "The size of the Ada type used to instantiate OR_MATCH");
  4290.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4291.             "does not correspond to the size of the " & COLUMN_NAME &
  4292.             " column");
  4293.             raise  X_INVALID_COLUMN;
  4294.         end if;
  4295.  
  4296.         case TABLE (IT).TABLE_DEFINITION.COLUMN_TYPES (IC) is
  4297.             when 1 | 2 => 
  4298. -- integer or float column
  4299.                 TRANSLATE (1) := USER_COLUMN_TO_INTEGER (COLUMN_VALUE);
  4300.                 MEANINGFUL := 1;
  4301.             when 5 =>
  4302.                 if TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC) /= null then
  4303.                     -- enumeration column
  4304.                     TRANSLATE (1) := INTEGER (USER_COLUMN_TO_INTEGER16
  4305.                                                         (COLUMN_VALUE));
  4306.                     MEANINGFUL := 1;
  4307.                 else
  4308.                     -- character string column
  4309.                     TRANSIT := USER_COLUMN_TO_TRANSIT (COLUMN_VALUE);
  4310.                     MEANINGFUL := (TRANSIT'LENGTH + 3) / 4;
  4311.                     TRANSLATE (1 .. MEANINGFUL) :=
  4312.                       CONVERSION.F77_STRING (TRANSIT);
  4313.                 end if;
  4314.  
  4315.             when others =>
  4316.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4317.                 "internal error when identifying the column type in OR_MATCH");
  4318.                 raise X_INTERNAL_ERROR;
  4319.         end case;
  4320.  
  4321.         if TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC) /= null then
  4322.                 -- a range constraint applies to the column;the
  4323.                 -- value must be checked not to violate this range.
  4324.             UTILITIES.CHECK_VALUE (TRANSLATE (1), IT, IC);
  4325.         end if;
  4326.  
  4327.         LAST_NODE := TABLE (IT).TABLE_STATUS.SELECTION_CRITERION;
  4328.  
  4329.         while LAST_NODE.all.OTHER /= null loop
  4330.             -- loop until the last component of the list is found
  4331.             LAST_NODE := LAST_NODE.all.OTHER;
  4332.         end loop;
  4333.  
  4334.         -- append a new node to the list
  4335.         LAST_NODE.all.OTHER := TABLE_DESCRIPTOR.NEW_NODE;
  4336.         LAST_NODE.all.OTHER.all :=
  4337.                    (COLUMN_ID                        => IC,
  4338.                     KEY_MATCH                        => KEY_MATCH,
  4339.                     COLUMN_VALUE                     => TRANSLATE,
  4340.                     MEANINGFUL                       => MEANINGFUL,
  4341.                     USER_OPERATOR | TREE_OPERATOR     => OR_OPERATOR,
  4342.                     FIRST_CHILD | SECOND_CHILD | OTHER => null);
  4343.     end OR_MATCH;
  4344.  
  4345.     procedure AND_MATCH (TABLE_NAME   : STRING;
  4346.                          COLUMN_NAME  : STRING;
  4347.                          KEY_MATCH    : KEY_MATCH_TYPE;
  4348.                          COLUMN_VALUE : USER_COLUMN) is
  4349. --************************************************************************
  4350. --**                                                                    **
  4351. --**   UNIT NAME :          AND_MATCH                                   **
  4352. --**   ~~~~~~~~~~~                                                      **
  4353. --** DESCRIPTION--------------------------------------------------------**
  4354. --**                                                                    **
  4355. --**    if not A_DATABASE_IS_OPEN then                                  **
  4356. --**        raise X_TABLE_NOT_LOCKED;                                   **
  4357. --**    end if;                                                         **
  4358. --**                                                                    **
  4359. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  4360. --**            -- i.e. the LOCK component of TABLE_NAME in the TABLE   **
  4361. --**            -- status array is 'unlocked'                           **
  4362. --**        raise X_TABLE_NOT_LOCKED;                                   **
  4363. --**    end if;                                                         **
  4364. --**                                                                    **
  4365. --**    if FIND_STATUS_IS_NOT_CRITERION then                            **
  4366. --**            -- the FIND_STATUS component of TABLE_NAME in the TABLE **
  4367. --**            -- status array is not 'criterion'.                     **
  4368. --**        raise X_NO_PREVIOUS_MATCH;                                  **
  4369. --**    end if;                                                         **
  4370. --**                                                                    **
  4371. --**    if COLUMN_NAME_DOES_NOT_EXIST then                              **
  4372. --**            -- COLUMN_NAME is not the name of one of the columns    **
  4373. --**            -- of the TABLE_NAME table, or is a record column.      **
  4374. --**        raise X_INVALID_COLUMN;                                     **
  4375. --**    end if;                                                         **
  4376. --**                                                                    **
  4377. --**    if COLUMN_TYPE_DOES_NOT_MATCH_INSTANTIATION_TYPE then           **
  4378. --**            -- information known by DAMES about the type of the     **
  4379. --**            -- COLUMN_NAME column does not match the USER_COLUMN    **
  4380. --**            -- type, which is defined when instantiating the        **
  4381. --**            -- generic AND_MATCH procedure.                         **
  4382. --**        raise X_INVALID_COLUMN;                                     **
  4383. --**    end if;                                                         **
  4384. --**                                                                    **
  4385. --**    if COLUMN_TYPE_DOES_NOT_MATCH_COLUMN_VALUE then                 **
  4386. --**            -- the type USER_COLUMN is then correct, but the value  **
  4387. --**            -- of the COLUMN_VALUE actual argument is not valid for **
  4388. --**            -- the COLUMN_NAME column type                          **
  4389. --**        raise X_INVALID_VALUE;                                      **
  4390. --**    end if;                                                         **
  4391. --**                                                                    **
  4392. --**    APPEND_TO_SELECTION_CRITERION ( AND,                            **
  4393. --**                                    COLUMN_NAME,                    **
  4394. --**                                    KEY_MATCH,                      **
  4395. --**                                    COLUMN_VALUE);                  **
  4396. --**        -- add to the current selection criterion another basic     **
  4397. --**        -- expression, which is :                                   **
  4398. --**        --         'COLUMN_NAME KEY_MATCH COLUMN_VALUE'             **
  4399. --**        -- This new basic expression is connected to the already    **
  4400. --**        -- defined ones with the AND logical operator.              **
  4401. --**        -- This criterion is specific to the TABLE_NAME table       **
  4402. --**                                                                    **
  4403. --**                                                                    **
  4404. --** INPUT--------------------------------------------------------------**
  4405. --**                                                                    **
  4406. --**  TABLE_NAME  is  the  name  of  the table on which the  selection  **
  4407. --**  criterion will be applied.                                        **
  4408. --**                                                                    **
  4409. --**  COLUMN_NAME is the name of the column to be used.                 **
  4410. --**                                                                    **
  4411. --**  KEY_MATCH is the match to be performed between the column of the  **
  4412. --**  candidate row and COLUMN_VALUE.                                   **
  4413. --**                                                                    **
  4414. --**  COLUMN_VALUE is the value to  be  compared  with the COLUMN_NAME  **
  4415. --**  column.                                                           **
  4416. --**                                                                    **
  4417. --** STATUS VARIABLES USED----------------------------------------------**
  4418. --**                                                                    **
  4419. --**    A_DATABASE_IS_OPEN                                              **
  4420. --**    TABLE.LOCK                                                      **
  4421. --**    TABLE.FIND_STATUS                                               **
  4422. --**                                                                    **
  4423. --** OUTPUT-------------------------------------------------------------**
  4424. --**                                                                    **
  4425. --**                                                                    **
  4426. --** STATUS VARIABLES UPDATED-------------------------------------------**
  4427. --**                                                                    **
  4428. --**    TABLE.SELECTION_CRITERION                                       **
  4429. --**                                                                    **
  4430. --** EXCEPTIONS---------------------------------------------------------**
  4431. --**                                                                    **
  4432. --**    X_INVALID_VALUE                                                 **
  4433. --**    X_INVALID_COLUMN                                                **
  4434. --**    X_TABLE_NOT_LOCKED                                              **
  4435. --**    X_NO_PREVIOUS_MATCH                                             **
  4436. --**                                                                    **
  4437. --************************************************************************
  4438.         IT, IC     : INTEGER;
  4439.         MEANINGFUL : NATURAL;
  4440.         TRANSLATE  : INTEGER_ARRAY_TYPE (1 .. (MAX_STRING + 3) / 4);
  4441.         LAST_NODE  : NODE_ACCESS;
  4442.  
  4443.         subtype NULL_STRING  is STRING (2 .. 1);
  4444.         subtype TRANSIT_TYPE is STRING
  4445.                                   (1 .. (USER_COLUMN'SIZE -
  4446.                                          NULL_STRING'SIZE) / CHARACTER'SIZE);
  4447.  
  4448.         TRANSIT : TRANSIT_TYPE;
  4449.  
  4450.         function USER_COLUMN_TO_TRANSIT is new UNCHECKED_CONVERSION
  4451.                    (USER_COLUMN, TRANSIT_TYPE);
  4452.         function USER_COLUMN_TO_INTEGER is new UNCHECKED_CONVERSION
  4453.                    (USER_COLUMN, INTEGER);
  4454.         function USER_COLUMN_TO_INTEGER16 is new UNCHECKED_CONVERSION
  4455.                    (USER_COLUMN, INTEGER16);
  4456.  
  4457.     begin
  4458.         if not SHARE.A_DATABASE_IS_OPEN then
  4459.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4460.             "A database must be opened and a table locked to use AND_MATCH");
  4461.             raise X_TABLE_NOT_LOCKED;
  4462.         end if;
  4463.  
  4464.         -- get the table index or raise X_TABLE_NOT_LOCKED
  4465.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  4466.  
  4467.         if TABLE (IT).TABLE_STATUS.FIND_STATUS /= CRITERION then
  4468.             -- the find-status is not 'criterion'; it means that the
  4469.             -- MATCH procedure has not been previously called, or has been
  4470.             -- followed by a FIND call
  4471.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4472.             "MATCH must be called before calling AND_MATCH");
  4473.             raise X_NO_PREVIOUS_MATCH;
  4474.         end if;
  4475.  
  4476.         -- get the index corresponding to COLUMN_NAME, assuming that
  4477.         -- this is the name of a scalar column, otherwise raise
  4478.         -- X_INVALID_COLUMN
  4479.         IC := UTILITIES.SCALAR_COLUMN_ID (IT, COLUMN_NAME);
  4480.  
  4481.         if COLUMN_VALUE'SIZE /= UTILITIES.BIT_SIZE (IT, IC) then
  4482.             -- the actual parameter size does not match the required size
  4483.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4484.             "The size of the Ada type used to instantiate AND_MATCH");
  4485.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4486.             "does not correspond to the size of the " & COLUMN_NAME &
  4487.             " column");
  4488.             raise X_INVALID_COLUMN;
  4489.         end if;
  4490.  
  4491.         case TABLE (IT).TABLE_DEFINITION.COLUMN_TYPES (IC) is
  4492.             when 1 | 2 => 
  4493. -- integer or float column
  4494.                 TRANSLATE (1) := USER_COLUMN_TO_INTEGER (COLUMN_VALUE);
  4495.                 MEANINGFUL := 1;
  4496.             when 5 =>
  4497.                 if TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC) /= null then
  4498.                     -- enumeration column
  4499.                     TRANSLATE (1) := INTEGER (USER_COLUMN_TO_INTEGER16
  4500.                                                         (COLUMN_VALUE));
  4501.                     MEANINGFUL := 1;
  4502.                 else
  4503.                     -- character string column
  4504.                     TRANSIT := USER_COLUMN_TO_TRANSIT (COLUMN_VALUE);
  4505.                     MEANINGFUL := (TRANSIT'LENGTH + 3) / 4;
  4506.                     TRANSLATE (1 .. MEANINGFUL) :=
  4507.                       CONVERSION.F77_STRING (TRANSIT);
  4508.                 end if;
  4509.  
  4510.             when others =>  null;
  4511.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4512.                "internal error when identifying the column type in AND_MATCH");
  4513.                 raise X_INTERNAL_ERROR;
  4514.         end case;
  4515.  
  4516.         if TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC) /= null then
  4517.                 -- a range constraint applies to the column;the
  4518.                 -- value must be checked not to violate this range.
  4519.             UTILITIES.CHECK_VALUE (TRANSLATE (1), IT, IC);
  4520.         end if;
  4521.  
  4522.         LAST_NODE := TABLE (IT).TABLE_STATUS.SELECTION_CRITERION;
  4523.  
  4524.         while LAST_NODE.all.OTHER /= null loop
  4525.             -- loop until the last component of the list is found
  4526.             LAST_NODE := LAST_NODE.all.OTHER;
  4527.         end loop;
  4528.  
  4529.         -- append a new node to the list
  4530.         LAST_NODE.all.OTHER := TABLE_DESCRIPTOR.NEW_NODE;
  4531.         LAST_NODE.all.OTHER.all :=
  4532.                    (COLUMN_ID                        => IC,
  4533.                     KEY_MATCH                        => KEY_MATCH,
  4534.                     COLUMN_VALUE                     => TRANSLATE,
  4535.                     MEANINGFUL                       => MEANINGFUL,
  4536.                     USER_OPERATOR | TREE_OPERATOR     => AND_OPERATOR,
  4537.                     FIRST_CHILD | SECOND_CHILD | OTHER => null);
  4538.     end AND_MATCH;
  4539.  
  4540.     procedure FIND (TABLE_NAME : STRING) is
  4541. --************************************************************************
  4542. --**                                                                    **
  4543. --**   UNIT NAME :          FIND                                        **
  4544. --**   ~~~~~~~~~~~                                                      **
  4545. --** DESCRIPTION--------------------------------------------------------**
  4546. --**                                                                    **
  4547. --**                                                                    **
  4548. --**    if not A_DATABASE_IS_OPEN then                                  **
  4549. --**        raise X_TABLE_NOT_LOCKED;                                   **
  4550. --**    end if;                                                         **
  4551. --**                                                                    **
  4552. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  4553. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  4554. --**            -- array is 'unlocked'                                  **
  4555. --**        raise X_TABLE_NOT_LOCKED;                                   **
  4556. --**    end if;                                                         **
  4557. --**                                                                    **
  4558. --**    if FIND_STATUS_IS_NOT_CRITERION then                            **
  4559. --**            -- the FIND_STATUS component of TABLE_NAME in the TABLE **
  4560. --**            -- status array is not 'criterion' (and so is either    **
  4561. --**            -- 'dead' or 'find').                                   **
  4562. --**        raise X_INVALID_CRITERION;                                  **
  4563. --**    end if;                                                         **
  4564. --**                                                                    **
  4565. --**    END_SELECTION_CRITERION;                                        **
  4566. --**        -- convert all information stored in SELECTION_CRITERION    **
  4567. --**        -- into a more suitable form for applying the criterion to  **
  4568. --**        -- each candidate row (a binary tree is in fact created).   **
  4569. --**                                                                    **
  4570. --**    INITIALIZE_CURRENT_ROW;                                         **
  4571. --**        -- set the CURRENT_ROW component of TABLE_NAME in the TABLE **
  4572. --**        -- status array to 'init', after calling the SETGET access  **
  4573. --**        -- procedure with appropriate arguments in order to select  **
  4574. --**        -- the first row matching the criterion.                    **
  4575. --**        -- The algorithm  to  be  used  to  find  this  first  row  **
  4576. --**        -- can depend on whether the table is sorted or not.        **
  4577. --**                                                                    **
  4578. --**    UPDATE_FIND_STATUS;                                             **
  4579. --**        -- set the FIND_STATUS component of TABLE_NAME in the TABLE **
  4580. --**        -- status array to 'find'                                   **
  4581. --**                                                                    **
  4582. --**                                                                    **
  4583. --** INPUT--------------------------------------------------------------**
  4584. --**                                                                    **
  4585. --**  TABLE_NAME is the name of the table to which the criterion  will  **
  4586. --**  be applied.                                                       **
  4587. --**                                                                    **
  4588. --** STATUS VARIABLES USED----------------------------------------------**
  4589. --**                                                                    **
  4590. --**    A_DATABASE_IS_OPEN                                              **
  4591. --**    TABLE.LOCK                                                      **
  4592. --**    TABLE.FIND_STATUS                                               **
  4593. --**                                                                    **
  4594. --** OUTPUT-------------------------------------------------------------**
  4595. --**                                                                    **
  4596. --**                                                                    **
  4597. --** STATUS VARIABLES UPDATED-------------------------------------------**
  4598. --**                                                                    **
  4599. --**    TABLE.FIND_STATUS                                               **
  4600. --**    TABLE.CURRENT_ROW                                               **
  4601. --**                                                                    **
  4602. --** EXCEPTIONS---------------------------------------------------------**
  4603. --**                                                                    **
  4604. --**    X_INVALID_CRITERION                                             **
  4605. --**    X_TABLE_NOT_LOCKED                                              **
  4606. --**                                                                    **
  4607. --************************************************************************
  4608.         RTN, IT                 : INTEGER;
  4609.         SAVE_FIRST_CHILD        : NODE_ACCESS;
  4610.         CURSOR, PREVIOUS_CURSOR : NODE_ACCESS;
  4611.         TIDD                    : TIDD_TYPE := (-1, 0, 0);
  4612.  
  4613.     begin
  4614.         if not SHARE.A_DATABASE_IS_OPEN then
  4615.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4616.             "A database must be opened and a table locked to use FIND");
  4617.             raise X_TABLE_NOT_LOCKED;
  4618.         end if;
  4619.  
  4620.         -- get the table index or raise X_TABLE_NOT_LOCKED
  4621.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  4622.  
  4623.         if TABLE (IT).TABLE_STATUS.FIND_STATUS /= CRITERION then
  4624.             -- the find-status is not 'criterion'; it means that the 
  4625.             -- MATCH procedure has not been previously called, or the
  4626.             -- call has been followed by a call to FIND
  4627.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4628.             "MATCH must be called before calling FIND");
  4629.             raise X_INVALID_CRITERION;
  4630.         end if;
  4631.  
  4632.         -- set PREVIOUS_CURSOR to the first item of the SELECTION_CRITERION
  4633.         -- list, and set CURSOR to the following one (or to null if there
  4634.         -- is only one item in the list)
  4635.         PREVIOUS_CURSOR := TABLE (IT).TABLE_STATUS.SELECTION_CRITERION;
  4636.         CURSOR := PREVIOUS_CURSOR.all.OTHER;
  4637.  
  4638.         while CURSOR /= null loop
  4639. -- loop until the end of the list is found            
  4640.  
  4641.             if CURSOR.all.USER_OPERATOR = AND_OPERATOR then
  4642.                 -- the currently found item has been written by the 
  4643.                 -- AND_MATCH procedure; the current item and the preceding
  4644.                 -- one must be joined to form a tree with a AND root, the
  4645.                 -- too first branches being the current and preceding
  4646.                 -- items, and this tree being inserted in the SELECTION_
  4647.                 -- CRITERION list where the current and preceding were;
  4648.                 -- for example, if the SELECTION_CRITERION list was :
  4649.                 -- 
  4650.                 --  C1 , or_C2  ,  or_and  ,  and_C5  ,  or_C6
  4651.                 --                   / \
  4652.                 --                  /   \
  4653.                 --                C3     C4
  4654.                 -- 
  4655.                 -- where the current item is the fourth one, the list would
  4656.                 -- then be changed to the following one :
  4657.                 -- 
  4658.                 --  C1 , or_C2  ,  or_and  ,  or_C6
  4659.                 --                    / \
  4660.                 --                   /   \
  4661.                 --                and     C5
  4662.                 --                / \
  4663.                 --               /   \
  4664.                 --             C3     C4
  4665.                 -- 
  4666.                 -- and the current item is left being the fourth one.
  4667.                 PREVIOUS_CURSOR.all.TREE_OPERATOR := AND_OPERATOR;
  4668.                 SAVE_FIRST_CHILD := PREVIOUS_CURSOR.all.FIRST_CHILD;
  4669.                 PREVIOUS_CURSOR.all.FIRST_CHILD :=
  4670.                         TABLE_DESCRIPTOR.NEW_NODE;
  4671.                 PREVIOUS_CURSOR.all.FIRST_CHILD.all :=
  4672.                            (COLUMN_ID     => PREVIOUS_CURSOR.all.COLUMN_ID,
  4673.                             KEY_MATCH     => PREVIOUS_CURSOR.all.KEY_MATCH,
  4674.                             COLUMN_VALUE  => PREVIOUS_CURSOR.all.COLUMN_VALUE,
  4675.                             MEANINGFUL    => PREVIOUS_CURSOR.all.MEANINGFUL,
  4676.                             USER_OPERATOR => OR_OPERATOR,
  4677.                             TREE_OPERATOR => PREVIOUS_CURSOR.all.TREE_OPERATOR,
  4678.                             FIRST_CHILD   => SAVE_FIRST_CHILD,
  4679.                             SECOND_CHILD  => PREVIOUS_CURSOR.all.SECOND_CHILD,
  4680.                             OTHER         => null);
  4681.                 PREVIOUS_CURSOR.all.SECOND_CHILD := CURSOR;
  4682.                 PREVIOUS_CURSOR.all.OTHER := CURSOR.all.OTHER;
  4683.                 CURSOR.all.OTHER := null;
  4684.                 CURSOR := PREVIOUS_CURSOR.all.OTHER;
  4685.             else
  4686.                 -- if the current item has not been generated by a
  4687.                 -- AND_MATCH call, advance to the next one
  4688.                 PREVIOUS_CURSOR := CURSOR;
  4689.                 CURSOR := CURSOR.all.OTHER;
  4690.             end if;
  4691.         end loop;
  4692.  
  4693.  
  4694.         -- let's do exactly the same thing but with the items which
  4695.         -- have been written by a OR_MATCH call; this order implies
  4696.         -- the precedence order between AND and OR operators.
  4697.  
  4698.         -- Only one item will remain in the list, which will be the
  4699.         -- root of the binary tree to be used for selection criterion;
  4700.         -- the list is then entirely changed into a tree.
  4701.  
  4702.  
  4703.         PREVIOUS_CURSOR := TABLE (IT).TABLE_STATUS.SELECTION_CRITERION;
  4704.         CURSOR := PREVIOUS_CURSOR.all.OTHER;
  4705.  
  4706.         while CURSOR /= null loop
  4707.             -- There is in fact no need to test the USER_OPERATOR since
  4708.             -- all remaining items(except the first one) have been written
  4709.             -- by using the OR_MATCH procedure
  4710.  
  4711.             PREVIOUS_CURSOR.all.TREE_OPERATOR := OR_OPERATOR;
  4712.             SAVE_FIRST_CHILD := PREVIOUS_CURSOR.all.FIRST_CHILD;
  4713.             PREVIOUS_CURSOR.all.FIRST_CHILD := TABLE_DESCRIPTOR.NEW_NODE;
  4714.             PREVIOUS_CURSOR.all.FIRST_CHILD.all :=
  4715.                        (COLUMN_ID     => PREVIOUS_CURSOR.all.COLUMN_ID,
  4716.                         KEY_MATCH     => PREVIOUS_CURSOR.all.KEY_MATCH,
  4717.                         COLUMN_VALUE  => PREVIOUS_CURSOR.all.COLUMN_VALUE,
  4718.                         MEANINGFUL    => PREVIOUS_CURSOR.all.MEANINGFUL,
  4719.                         USER_OPERATOR => OR_OPERATOR,
  4720.                         TREE_OPERATOR => PREVIOUS_CURSOR.all.TREE_OPERATOR,
  4721.                         FIRST_CHILD   => SAVE_FIRST_CHILD,
  4722.                         SECOND_CHILD  => PREVIOUS_CURSOR.all.SECOND_CHILD,
  4723.                         OTHER         => null);
  4724.             PREVIOUS_CURSOR.all.SECOND_CHILD := CURSOR;
  4725.             PREVIOUS_CURSOR.all.OTHER := CURSOR.all.OTHER;
  4726.             CURSOR.all.OTHER := null;
  4727.             CURSOR := PREVIOUS_CURSOR.all.OTHER;
  4728.         end loop;
  4729.         -- the first component of CURRENT_ROW set to -1 means that no
  4730.         -- row has been yet selected (this value is meaningful for 
  4731.         -- the fortran access procedures and for the interface itself
  4732.         -- too)
  4733.         TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) := -1;
  4734.  
  4735.         -- preselect all rows of the table
  4736.         F77_CALLABLES.ADA_SETGET
  4737.            (TABLE (IT).TABLE_STATUS.DESCR, 3, TIDD, TIDD, RTN);
  4738.         if RTN /= 0 then
  4739.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4740.             "internal error in FIND");
  4741.             raise X_INTERNAL_ERROR;
  4742.         end if;
  4743.  
  4744.         -- set the find-status of the table to 'find'
  4745.         TABLE (IT).TABLE_STATUS.FIND_STATUS := FIND;
  4746.     end FIND;
  4747.  
  4748.  
  4749.     function FIND_NEXT (TABLE_NAME : STRING) return BOOLEAN is
  4750. --************************************************************************
  4751. --**                                                                    **
  4752. --**   UNIT NAME :          FIND_NEXT                                   **
  4753. --**   ~~~~~~~~~~~                                                      **
  4754. --** DESCRIPTION--------------------------------------------------------**
  4755. --**                                                                    **
  4756. --**    if not A_DATABASE_IS_OPEN then                                  **
  4757. --**        raise X_TABLE_NOT_LOCKED;                                   **
  4758. --**    end if;                                                         **
  4759. --**                                                                    **
  4760. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  4761. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  4762. --**            -- array is 'unlocked'                                  **
  4763. --**        raise X_TABLE_NOT_LOCKED;                                   **
  4764. --**    end if;                                                         **
  4765. --**                                                                    **
  4766. --**    if FIND_STATUS_IS_NOT_FIND then                                 **
  4767. --**            -- the FIND_STATUS component of TABLE_NAME in the TABLE **
  4768. --**            -- status array is not 'find' (and  so  is either       **
  4769. --**            -- 'dead' or 'criterion').                              **
  4770. --**        raise X_NO_PREVIOUS_FIND;                                   **
  4771. --**    end if;                                                         **
  4772. --**                                                                    **
  4773. --**    if LAST_ROW_WAS_ALREADY_FOUND then                              **
  4774. --**            -- this occurs when the CURRENT_ROW component of        **
  4775. --**            -- TABLE_NAME in the TABLE status array is 'end'        **
  4776. --**        raise X_NO_MORE_ROWS;                                       **
  4777. --**    end if;                                                         **
  4778. --**                                                                    **
  4779. --**    REPLACE_CURRENT_ROW_BY_THE_FOLLOWING_ONE;                 **
  4780. --**    if NO_MORE_ROWS then                                            **
  4781. --**            -- no more rows match the selection criterion           **
  4782. --**                                                                    **
  4783. --**        SET_CURRENT_ROW_TO_END (TABLE_NAME);                        **
  4784. --**            -- the CURRENT_ROW component of TABLE_NAME in the TABLE **
  4785. --**            -- status array is set to 'end'                         **
  4786. --**                                                                    **
  4787. --**        return FALSE;                                               **
  4788. --**    end if;                                                         **
  4789. --**                                                                    **
  4790. --**    while SELECTION_CRITERION_IS_FALSE_FOR_THE_CURRENT_ROW loop     **
  4791. --**            -- loop as long as the criterion selection remains FALSE**
  4792. --**                                                                    **
  4793. --**        REPLACE_CURRENT_ROW_BY_THE_FOLLOWING_ONE;                   **
  4794. --**        if NO_MORE_ROWS then                                        **
  4795. --**                -- no more rows match the selection criterion       **
  4796. --**                                                                    **
  4797. --**            SET_CURRENT_ROW_TO_END (TABLE_NAME);                    **
  4798. --**                -- the CURRENT_ROW component of TABLE_NAME in the   **
  4799. --**                -- TABLE status array is set to 'end'               **
  4800. --**                                                                    **
  4801. --**            return FALSE;                                           **
  4802. --**        end if;                                                     **
  4803. --**                                                                    **
  4804. --**    end loop;                                                       **
  4805. --**                                                                    **
  4806. --**        -- at least one row remains matching the selection criterion**
  4807. --**    return TRUE;                                                    **
  4808. --**                                                                    **
  4809. --**                                                                    **
  4810. --** INPUT--------------------------------------------------------------**
  4811. --**                                                                    **
  4812. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  4813. --**                                                                    **
  4814. --** STATUS VARIABLES USED----------------------------------------------**
  4815. --**                                                                    **
  4816. --**    A_DATABASE_IS_OPEN                                              **
  4817. --**    TABLE.LOCK                                                      **
  4818. --**    TABLE.FIND_STATUS                                               **
  4819. --**    TABLE.SELECTION_CRITERION                                       **
  4820. --**                                                                    **
  4821. --** OUTPUT-------------------------------------------------------------**
  4822. --**                                                                    **
  4823. --**                                                                    **
  4824. --** STATUS VARIABLES UPDATED-------------------------------------------**
  4825. --**                                                                    **
  4826. --**    TABLE.CURRENT_ROW                                               **
  4827. --**                                                                    **
  4828. --** EXCEPTIONS---------------------------------------------------------**
  4829. --**                                                                    **
  4830. --**    X_TABLE_NOT_LOCKED                                              **
  4831. --**    X_NO_MORE_ROWS                                                  **
  4832. --**    X_NO_PREVIOUS_FIND                                              **
  4833. --**                                                                    **
  4834. --************************************************************************
  4835.         IT, RTN : INTEGER;
  4836.     begin
  4837.         if not SHARE.A_DATABASE_IS_OPEN then
  4838.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4839.             "A database must be opened and a table locked to use FIND_NEXT");
  4840.             raise X_TABLE_NOT_LOCKED;
  4841.         end if;
  4842.  
  4843.         -- get the index of the table or raise X_TABLE_NOT_LOCKED
  4844.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  4845.  
  4846.         if TABLE (IT).TABLE_STATUS.FIND_STATUS /= FIND then
  4847.             -- the find-status is not 'find'; it means the FIND procedure
  4848.             -- has not been previously called
  4849.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4850.             "FIND must be called before using FIND_NEXT");
  4851.             raise X_NO_PREVIOUS_FIND;
  4852.         end if;
  4853.  
  4854.         if TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = 0 then
  4855.             -- the value zero means the end of the table has been already 
  4856.             -- reached
  4857.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4858.             "FIND_NEXT must not be called again when the end of the table");
  4859.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4860.             "has already been reached");
  4861.             raise X_NO_MORE_ROWS;
  4862.         end if;
  4863.  
  4864.         -- get the following row into the temporary row
  4865.         F77_CALLABLES.ADA_GETT
  4866.            (TABLE (IT).TABLE_STATUS.DESCR,
  4867.             TABLE (IT).TABLE_STATUS.CURRENT_ROW, RTN);      ------------------
  4868.                                                             -- 
  4869.         if TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = 0 then
  4870.             -- ou bien RTN = 1
  4871.             -- the current row was the last one         --
  4872.             return FALSE;                                   ------------------
  4873.         end if;
  4874.  
  4875.         while not UTILITIES.SELECTION_CRITERION_IS_TRUE
  4876.                      (IT, TABLE (IT).TABLE_STATUS.SELECTION_CRITERION) loop
  4877.             -- loop until the selection criterion is true
  4878.  
  4879.             -- get the following row into the temporary row
  4880.             F77_CALLABLES.ADA_GETT
  4881.                (TABLE (IT).TABLE_STATUS.DESCR,
  4882.                 TABLE (IT).TABLE_STATUS.CURRENT_ROW, RTN);
  4883.  
  4884.             -- the current row was the last one             -------------
  4885.             if TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = 0 then
  4886.                 -- ou bien
  4887.                 return FALSE;                                   -- RTN = 1
  4888.             end if;
  4889.             -------------
  4890.         end loop;
  4891.  
  4892.         -- a row for which the selection criterion is true has been
  4893.         -- found
  4894.         return TRUE;
  4895.     end FIND_NEXT;
  4896.     function FIND_PREVIOUS (TABLE_NAME : STRING) return BOOLEAN is
  4897. --************************************************************************
  4898. --**                                                                    **
  4899. --**   UNIT NAME :          FIND_PREVIOUS                               **
  4900. --**   ~~~~~~~~~~~                                                      **
  4901. --** DESCRIPTION--------------------------------------------------------**
  4902. --**                                                                    **
  4903. --**                                                                    **
  4904. --**    if not A_DATABASE_IS_OPEN then                                  **
  4905. --**        raise X_TABLE_NOT_LOCKED;                                   **
  4906. --**    end if;                                                         **
  4907. --**                                                                    **
  4908. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  4909. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  4910. --**            -- array is 'unlocked'                                  **
  4911. --**        raise X_TABLE_NOT_LOCKED;                                   **
  4912. --**    end if;                                                         **
  4913. --**                                                                    **
  4914. --**    if FIND_STATUS_IS_NOT_FIND then                                 **
  4915. --**            -- the FIND_STATUS component of TABLE_NAME in the TABLE **
  4916. --**            -- status array is not 'find' (and  so  is either       **
  4917. --**            -- 'dead' or 'criterion').                              **
  4918. --**        raise X_NO_PREVIOUS_FIND;                                   **
  4919. --**    end if;                                                         **
  4920. --**                                                                    **
  4921. --**    if LAST_ROW_WAS_ALREADY_FOUND then                              **
  4922. --**            -- this occurs when the CURRENT_ROW component of        **
  4923. --**            -- TABLE_NAME in the TABLE status array is 'end'        **
  4924. --**            -- or 'init'                                            **
  4925. --**        raise X_NO_MORE_ROWS;                                       **
  4926. --**    end if;                                                         **
  4927. --**                                                                    **
  4928. --**    REPLACE_CURRENT_ROW_BY_THE_PRECEDING_ONE;                       **
  4929. --**    if NO_MORE_ROWS then                                            ** 
  4930. --**            -- no more rows match the selection criterion           **
  4931. --**        SET_CURRENT_ROW_TO_END (TABLE_NAME);                        **
  4932. --**            -- the CURRENT_ROW component of TABLE_NAME in the TABLE **
  4933. --**            -- status array is set to 'end'                         **
  4934. --**                                                                    **
  4935. --**        return FALSE;                                               **
  4936. --**    end if;                                                         **
  4937. --**                                                                    **
  4938. --**    while SELECTION_CRITERION_IS_FALSE_FOR_THE_CURRENT_ROW loop     **
  4939. --**            -- loop as long as the criterion selection remains FALSE**
  4940. --**                                                                    **
  4941. --**        REPLACE_CURRENT_ROW_BY_THE_PRECEDING_ONE;                   **
  4942. --**        if NO_MORE_ROWS then                                        **
  4943. --**                -- no more rows match the selection criterion       **
  4944. --**            SET_CURRENT_ROW_TO_END (TABLE_NAME);                    **
  4945. --**                -- the CURRENT_ROW component of TABLE_NAME in the   **
  4946. --**                -- TABLE status array is set to 'end'               **
  4947. --**                                                                    **
  4948. --**            return FALSE;                                           **
  4949. --**        end if;                                                     **
  4950. --**                                                                    **
  4951. --**    end loop;                                                       **
  4952. --**                                                                    **
  4953. --**        -- at least one row remains matching the selection criterion**
  4954. --**    return TRUE;                                                    **
  4955. --**                                                                    **
  4956. --**                                                                    **
  4957. --** INPUT--------------------------------------------------------------**
  4958. --**                                                                    **
  4959. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  4960. --**                                                                    **
  4961. --** STATUS VARIABLES USED----------------------------------------------**
  4962. --**                                                                    **
  4963. --**    A_DATABASE_IS_OPEN                                              **
  4964. --**    TABLE.LOCK                                                      **
  4965. --**    TABLE.FIND_STATUS                                               **
  4966. --**    TABLE.SELECTION_CRITERION                                       **
  4967. --**                                                                    **
  4968. --** OUTPUT-------------------------------------------------------------**
  4969. --**                                                                    **
  4970. --**                                                                    **
  4971. --** STATUS VARIABLES UPDATED-------------------------------------------**
  4972. --**                                                                    **
  4973. --**    TABLE.CURRENT_ROW                                               **
  4974. --**                                                                    **
  4975. --** EXCEPTIONS---------------------------------------------------------**
  4976. --**                                                                    **
  4977. --**    X_TABLE_NOT_LOCKED                                              **
  4978. --**    X_NO_MORE_ROWS                                                  **
  4979. --**    X_NO_PREVIOUS_FIND                                              **
  4980. --**                                                                    **
  4981. --************************************************************************
  4982.         IT, RTN : INTEGER;
  4983.     begin
  4984.         if not SHARE.A_DATABASE_IS_OPEN then
  4985.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4986.             "A database must be opened to use FIND_PREVIOUS");
  4987.             raise X_TABLE_NOT_LOCKED;
  4988.         end if;
  4989.  
  4990.         -- get the index of the table or raise X_TABLE_NOT_LOCKED
  4991.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  4992.  
  4993.         if TABLE (IT).TABLE_STATUS.FIND_STATUS /= FIND then
  4994.             -- the find-status is not 'find'; it means the FIND procedure
  4995.             -- has not been previously called
  4996.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  4997.             "FIND must be called before using FIND_PREVIOUS");
  4998.             raise X_NO_PREVIOUS_FIND;
  4999.         end if;
  5000.  
  5001.         if TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = -1 or
  5002.            TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = 0 then
  5003.             -- the value zero means the end of the table has been already 
  5004.             -- reached, and the value -1 means that the first row has not 
  5005.             -- been yet selected
  5006.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5007.             "FIND_PREVIOUS must not be called again when the beginning of");
  5008.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5009.             "the table has already been reached");
  5010.             raise X_NO_MORE_ROWS;
  5011.         end if;
  5012.  
  5013.         -- get the preceding row into the temporary row
  5014.         F77_CALLABLES.ADA_DPREV
  5015.            (TABLE (IT).TABLE_STATUS.DESCR,
  5016.             TABLE (IT).TABLE_STATUS.CURRENT_ROW, RTN);
  5017.  
  5018.         if RTN /= 0 then
  5019.             -- the current row was the first one
  5020.             TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) := 0;
  5021.             return FALSE;                                                
  5022.         end if;
  5023.  
  5024.         while not UTILITIES.SELECTION_CRITERION_IS_TRUE
  5025.                      (IT, TABLE (IT).TABLE_STATUS.SELECTION_CRITERION) loop
  5026.             -- loop until the selection criterion is true
  5027.  
  5028.             -- get the preceding row into the temporary row
  5029.             F77_CALLABLES.ADA_DPREV
  5030.                (TABLE (IT).TABLE_STATUS.DESCR,
  5031.                 TABLE (IT).TABLE_STATUS.CURRENT_ROW, RTN);
  5032.  
  5033.             if RTN /= 0 then
  5034.                 -- the current row was the first one
  5035.                 TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) := 0;
  5036.                 return FALSE;
  5037.             end if;
  5038.         end loop;
  5039.  
  5040.         -- a row for which the selection criterion is true has been
  5041.         -- found
  5042.         return TRUE;
  5043.     end FIND_PREVIOUS;
  5044.  
  5045.     function NEXT (TABLE_NAME : STRING) return BOOLEAN is
  5046. --************************************************************************
  5047. --**                                                                    **
  5048. --**   UNIT NAME :          NEXT                                        **
  5049. --**   ~~~~~~~~~~~                                                      **
  5050. --** DESCRIPTION--------------------------------------------------------**
  5051. --**                                                                    **
  5052. --**    if not A_DATABASE_IS_OPEN then                                  **
  5053. --**        raise X_TABLE_NOT_LOCKED;                                   **
  5054. --**    end if;                                                         **
  5055. --**                                                                    **
  5056. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  5057. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  5058. --**            -- array is 'unlocked'                                  **
  5059. --**        raise X_TABLE_NOT_LOCKED;                                   **
  5060. --**    end if;                                                         **
  5061. --**                                                                    **
  5062. --**    if LAST_ROW_WAS_ALREADY_FOUND then                              **
  5063. --**            -- this occurs when the CURRENT_ROW component of        **
  5064. --**            -- TABLE_NAME in the TABLE status array is 'end'        **
  5065. --**        raise X_NO_MORE_ROWS;                                       **
  5066. --**    end if;                                                         **
  5067. --**                                                                    **
  5068. --**    REPLACE_CURRENT_ROW_BY_THE_FOLLOWING_ONE;                       **
  5069. --**    if NO_MORE_ROWS then                                            **
  5070. --**            -- no more rows in the table                            **
  5071. --**        SET_CURRENT_ROW_TO_END (TABLE_NAME);                        **
  5072. --**            -- the CURRENT_ROW component of TABLE_NAME in the TABLE **
  5073. --**            -- status array is set to 'end'                         **
  5074. --**                                                                    **
  5075. --**        return FALSE;                                               **
  5076. --**    else                                                            **
  5077. --**            -- at least one row remains in the table                **
  5078. --**        return TRUE;                                                **
  5079. --**    end if;                                                         **
  5080. --**                                                                    **
  5081. --** INPUT--------------------------------------------------------------**
  5082. --**                                                                    **
  5083. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  5084. --**                                                                    **
  5085. --** STATUS VARIABLES USED----------------------------------------------**
  5086. --**                                                                    **
  5087. --**    A_DATABASE_IS_USED                                              **
  5088. --**    TABLE.LOCK                                                      **
  5089. --**                                                                    **
  5090. --** OUTPUT-------------------------------------------------------------**
  5091. --**                                                                    **
  5092. --**                                                                    **
  5093. --** STATUS VARIABLES UPDATED-------------------------------------------**
  5094. --**                                                                    **
  5095. --**    TABLE.CURRENT_ROW                                               **
  5096. --**                                                                    **
  5097. --** EXCEPTIONS---------------------------------------------------------**
  5098. --**                                                                    **
  5099. --**    X_TABLE_NOT_LOCKED                                              ** 
  5100. --**    X_NO_MORE_ROWS                                                  ** 
  5101. --**                                                                    **
  5102. --**                                                                    **
  5103. --************************************************************************
  5104.         IT, RTN : INTEGER;
  5105.     begin
  5106.         if not SHARE.A_DATABASE_IS_OPEN then
  5107.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5108.             "A database must be opened and a table locked to use NEXT");
  5109.             raise X_TABLE_NOT_LOCKED;
  5110.         end if;
  5111.  
  5112.         -- get the table index or raise X_TABLE_NOT_LOCKED
  5113.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  5114.  
  5115.         if TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = 0 then
  5116.             -- a null first component for CURRENT_ROW means the end of
  5117.             -- the table has already been reached
  5118.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5119.             "NEXT must not be called again when the end of the table");
  5120.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5121.             "has already been reached");
  5122.             raise X_NO_MORE_ROWS;
  5123.         end if;
  5124.  
  5125.         -- get the following row, if any
  5126.         F77_CALLABLES.ADA_GETT
  5127.            (TABLE (IT).TABLE_STATUS.DESCR,
  5128.             TABLE (IT).TABLE_STATUS.CURRENT_ROW, RTN);      ------------------
  5129.                                                             -- 
  5130.         if TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = 0 then
  5131.             -- ou bien RTN = 1
  5132.             -- the current row was the last one         --
  5133.             return FALSE;                                   ------------------
  5134.         else
  5135.             -- the current row is now the one which follows the 
  5136.             -- ancient current row
  5137.             return TRUE;
  5138.         end if;
  5139.     end NEXT;
  5140.  
  5141.     function PREVIOUS (TABLE_NAME : STRING) return BOOLEAN is
  5142. --************************************************************************
  5143. --**                                                                    **
  5144. --**   UNIT NAME :          PREVIOUS                                    **
  5145. --**   ~~~~~~~~~~~                                                      **
  5146. --** DESCRIPTION--------------------------------------------------------**
  5147. --**                                                                    **
  5148. --**    if not A_DATABASE_IS_OPEN then                                  **
  5149. --**        raise X_TABLE_NOT_LOCKED;                                   **
  5150. --**    end if;                                                         **
  5151. --**                                                                    **
  5152. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  5153. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  5154. --**            -- array is 'unlocked'                                  **
  5155. --**        raise X_TABLE_NOT_LOCKED;                                   **
  5156. --**    end if;                                                         **
  5157. --**                                                                    **
  5158. --**    if LAST_ROW_WAS_ALREADY_FOUND then                              **
  5159. --**            -- this occurs when the CURRENT_ROW component of        **
  5160. --**            -- TABLE_NAME in the TABLE status array is 'end' or     **
  5161. --**            -- 'init'                                               **
  5162. --**        raise X_NO_MORE_ROWS;                                       **
  5163. --**    end if;                                                         **
  5164. --**                                                                    **
  5165. --**    REPLACE_CURRENT_ROW_BY_THE_PRECEDING_ONE;                       **
  5166. --**    if NO_MORE_ROWS then                                            **
  5167. --**            -- no more rows in the table                            **
  5168. --**        SET_CURRENT_ROW_TO_END (TABLE_NAME);                        **
  5169. --**            -- the CURRENT_ROW component of TABLE_NAME in the TABLE **
  5170. --**            -- status array is set to 'end'                         **
  5171. --**                                                                    **
  5172. --**        return FALSE;                                               **
  5173. --**    else                                                            **
  5174. --**            -- at least one row remains in the table                **
  5175. --**        return TRUE;                                                **
  5176. --**    end if;                                                         **
  5177. --**                                                                    **
  5178. --**                                                                    **
  5179. --** INPUT--------------------------------------------------------------**
  5180. --**                                                                    **
  5181. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  5182. --**                                                                    **
  5183. --** STATUS VARIABLES USED----------------------------------------------**
  5184. --**                                                                    **
  5185. --**    A_DATABASE_IS_OPEN                                              **
  5186. --**    TABLE.LOCK                                                      **
  5187. --**                                                                    **
  5188. --** OUTPUT-------------------------------------------------------------**
  5189. --**                                                                    **
  5190. --**                                                                    **
  5191. --** STATUS VARIABLES UPDATED-------------------------------------------**
  5192. --**                                                                    **
  5193. --**    TABLE.CURRENT_ROW                                               **
  5194. --**                                                                    **
  5195. --** EXCEPTIONS---------------------------------------------------------**
  5196. --**                                                                    **
  5197. --**    X_TABLE_NOT_LOCKED                                              **
  5198. --**    X_NO_MORE_ROWS                                                  **
  5199. --**                                                                    **
  5200. --************************************************************************
  5201.         IT, RTN : INTEGER;
  5202.     begin
  5203.         if not SHARE.A_DATABASE_IS_OPEN then
  5204.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5205.             "A database must be opened and a table locked to use PREVIOUS");
  5206.             raise X_TABLE_NOT_LOCKED;
  5207.         end if;
  5208.  
  5209.         -- get the table index or raise X_TABLE_NOT_LOCKED
  5210.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  5211.  
  5212.         if TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = -1 or
  5213.            TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = 0 then
  5214.             -- the first component of CURRENT_ROW set to -1 means that
  5215.             -- the first row has not been selected yet; 0 means there
  5216.             -- is no current row.
  5217.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5218.             "PREVIOUS must not be called again when the beginning of the");
  5219.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5220.             "table has already been reached");
  5221.             raise X_NO_MORE_ROWS;
  5222.         end if;
  5223.  
  5224.         -- select the previous row
  5225.         F77_CALLABLES.ADA_DPREV
  5226.            (TALE_STATUS.DESCR,
  5227.             TABLE (IT).TABLE_STATUS.CURRENT_ROW, RTN);
  5228.  
  5229.         if RTN /= 0 then
  5230.             -- the current row was the first one, and thus no preceding
  5231.             -- row has been found
  5232.             TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) := 0;
  5233.             return FALSE;
  5234.         else
  5235.             -- the current row isnow the row which preceded the ancient
  5236.             -- current row
  5237.             return TRUE;
  5238.         end if;
  5239.     end PREVIOUS;
  5240.  
  5241.     procedure GET_COLUMN (TABLE_NAME  : STRING;
  5242.                           COLUMN_NAME : STRING;
  5243.                           ITEM        : out USER_COLUMN) is
  5244. --************************************************************************
  5245. --**                                                                    **
  5246. --**   UNIT NAME :          GET_COLUMN                                  **
  5247. --**   ~~~~~~~~~~~                                                      **
  5248. --** DESCRIPTION--------------------------------------------------------**
  5249. --**                                                                    **
  5250. --**                                                                    **
  5251. --**    if not A_DATABASE_IS_OPEN then                                  **
  5252. --**        raise X_TABLE_NOT_LOCKED;                                   **
  5253. --**    end if;                                                         **
  5254. --**                                                                    **
  5255. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  5256. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  5257. --**            -- array is 'unlocked'                                  **
  5258. --**        raise X_TABLE_NOT_LOCKED;                                   **
  5259. --**    end if;                                                         **
  5260. --**                                                                    **
  5261. --**    if THERE_IS_NO_CURRENT_ROW then                                 **
  5262. --**            -- the CURRENT_ROW component of TABLE_NAME in the TABLE **
  5263. --**            -- status array is 'init' or 'end'                      **
  5264. --**        raise X_NO_CURRENT_ROW;                                     **
  5265. --**    end if;                                                         **
  5266. --**                                                                    **
  5267. --**    if COLUMN_NAME_DOES_NOT_EXIST then                              **
  5268. --**            -- COLUMN_NAME is not the name of one of the columns    **
  5269. --**            -- of the TABLE_NAME table                              **
  5270. --**        raise X_INVALID_COLUMN;                                     **
  5271. --**    end if;                                                         **
  5272. --**                                                                    **
  5273. --**    if COLUMN_TYPE_DOES_NOT_MATCH_INSTANTIATION_TYPE then           **
  5274. --**            -- information known by DAMES about the type of the     **
  5275. --**            -- COLUMN_NAME column does not match the USER_COLUMN    **
  5276. --**            -- type, which is defined when instantiating the        **
  5277. --**            -- generic GET_COLUMN procedure.                        **
  5278. --**        raise X_INVALID_COLUMN;                                     **
  5279. --**    end if;                                                         **
  5280. --**                                                                    **
  5281. --**    if COLUMN_TYPE_IS_RECORD then                                   **
  5282. --**                                                                    **
  5283. --**        for COMPONENT in COLUMN_COMPONENTS loop                     **
  5284. --**                                                                    **
  5285. --**            GET_VALUE_FROM_DATABASE (COMPONENT);                    **
  5286. --**                -- the value is read in a fortran77 format and is   **
  5287. --**                -- contained in an array of 32-bit integers.        **
  5288. --**                                                                    **
  5289. --**            TRANSLATE_FROM_FORTRAN77_TO_ADA;                        **
  5290. --**                -- the value is translated from fortran77 format    **
  5291. --**                -- to ada format, and is stored in an array of      **
  5292. --**                -- 16-bit integers.                                 **
  5293. --**                                                                    **
  5294. --**            if COLUMN_TYPE_DOES_NOT_MATCH_COLUMN_VALUE then         **
  5295. --**                -- the type USER_COLUMN is then correct, but the    **
  5296. --**                -- value read from the table is not valid for the   **
  5297. --**                -- COMPONENT column type as described in the        **
  5298. --**                -- database                                         **
  5299. --**                                                                    **
  5300. --**            INSERT_VALUE_INTO_ITEM (COMPONENT);                     **
  5301. --**        end loop;                                                   **
  5302. --**    else    -- the COLUMN_NAME column is of a scalar type           **
  5303. --**                                                                    **
  5304. --**        GET_VALUE_FROM_DATABASE (COLUMN_NAME);                      **
  5305. --**            -- the value is read in a fortran77 format and is       **
  5306. --**            -- contained in an array of 32-bit integers.            **
  5307. --**                                                                    **
  5308. --**        TRANSLATE_FROM_FORTRAN77_TO_ADA;                            **
  5309. --**            -- the value is translated from fortran77 format        **
  5310. --**            -- to ada format, and is stored in an array of          **
  5311. --**            -- 16-bit integers.                                     **
  5312. --**                                                                    **
  5313. --**        if COLUMN_TYPE_DOES_NOT_MATCH_COLUMN_VALUE then             **
  5314. --**            -- the type USER_COLUMN is then correct, but the        **
  5315. --**            -- value read from the table is not valid for the       **
  5316. --**            -- COLUMN_NAME column type as described in the          **
  5317. --**            -- database                                             **
  5318. --**                                                                    **
  5319. --**        COPY_VALUE_INTO_ITEM (COLUMN_NAME);                         **
  5320. --**    end if;                                                         **
  5321. --**                                                                    **
  5322. --**                                                                    **
  5323. --** INPUT--------------------------------------------------------------**
  5324. --**                                                                    **
  5325. --**  TABLE_NAME : name of the table to be read.                        **
  5326. --**  COLUMN_NAME  :  name  of  the  column  to  be  read;  its   type  **
  5327. --**  must be USER_COLUMN.                                              **
  5328. --**                                                                    **
  5329. --** STATUS VARIABLES USED----------------------------------------------**
  5330. --**                                                                    **
  5331. --**    A_DATABASE_IS_OPEN                                              **
  5332. --**    TABLE.LOCK                                                      **
  5333. --**                                                                    **
  5334. --** OUTPUT-------------------------------------------------------------**
  5335. --**                                                                    **
  5336. --**  ITEM  :  is the contents  of  the  column  COLUMN_NAME  of  the   **
  5337. --**           current row.                                             **
  5338. --**                                                                    **
  5339. --** STATUS VARIABLES UPDATED-------------------------------------------**
  5340. --**                                                                    **
  5341. --**                                                                    **
  5342. --** EXCEPTIONS---------------------------------------------------------**
  5343. --**                                                                    **
  5344. --**    X_TABLE_NOT_LOCKED                                              **
  5345. --**    X_INVALID_VALUE                                                 **
  5346. --**    X_INVALID_COLUMN                                                **
  5347. --**    X_NO_CURRENT_ROW                                                **
  5348. --**                                                                    **
  5349. --**                                                                    **
  5350. --************************************************************************
  5351.         USEFUL, IT, IC  : INTEGER;
  5352.         IS_RECORD       : BOOLEAN;
  5353.         LENR, FTYP, RTN : INTEGER;
  5354.         CHECKED         : INTEGER;
  5355.         RECORD_NAME     : STRING (1 .. NAME_LENGTH);
  5356.         STRING_ITEM : STRING (1 .. MAX_STRING);
  5357.         COMPONENT16 : INTEGER16_ARRAY_TYPE (1 .. MAX_STRING);
  5358.         COMPONENT   : INTEGER_ARRAY_TYPE (1 .. (3 + MAX_STRING) / 4);
  5359.         ITEM_COPY   : USER_COLUMN;
  5360.         TEMP        : CONVERSION.TWO_WORDS;
  5361.  
  5362.         procedure ADD_COMPONENT_TO_USER_COLUMN is new
  5363.                 CONVERSION.ADD_COMPONENT (USER_COLUMN);
  5364.  
  5365.     begin
  5366.         if not SHARE.A_DATABASE_IS_OPEN then
  5367.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5368.             "A database must be opened and a table locked to use GET_COLUMN");
  5369.             raise X_TABLE_NOT_LOCKED;
  5370.         end if;
  5371.  
  5372.         -- get the table index or raise X_TABLE_NOT_LOCKED
  5373.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  5374.  
  5375.         if TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = -1 or
  5376.            TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = 0 then
  5377.             -- there is no current row
  5378.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5379.             "A row must be selected by successfully using NEXT, PREVIOUS,");
  5380.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5381.             "FIND_NEXT or FIND_PREVIOUS before using GET_COLUMN");
  5382.             raise X_NO_CURRENT_ROW;
  5383.         end if;
  5384.  
  5385.         -- get in IC the index of the COLUMN_NAME column, and in
  5386.         -- IS_RECORD, put 'false' if COLUMN_NAME is a scalar column
  5387.         -- and 'true' otherwise; X_INVALID_COLUMN is raised if no
  5388.         -- scalar nor record column is found with this name
  5389.         UTILITIES.COLUMN (IT, COLUMN_NAME, IC, IS_RECORD);
  5390.  
  5391.         if USER_COLUMN'SIZE /=
  5392.            UTILITIES.RECORD_BIT_SIZE (IT, IC, IS_RECORD) then
  5393.             -- the size of the actual parameter USER_COLUMN is not
  5394.             -- this requested
  5395.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5396.             "The size of the Ada type used to instantiate GET_COLUMN");
  5397.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5398.             "does not correspond to the size of the " & COLUMN_NAME &
  5399.             " column");
  5400.             raise X_INVALID_COLUMN;
  5401.         end if;
  5402.  
  5403.         if IS_RECORD then
  5404.             -- the column to be read is a record column
  5405.  
  5406.             -- get the name of its column
  5407.             RECORD_NAME := TABLE (IT).TABLE_DEFINITION.IN_RECORD (IC);
  5408.  
  5409.             while TABLE (IT).TABLE_DEFINITION.IN_RECORD (IC) = RECORD_NAME loop
  5410.                 -- loop for each of the components of the record column
  5411.                 COMPONENT := (others => 0);
  5412.  
  5413.                 -- get into COMPONENT the actual value of the ICth column
  5414.                 F77_CALLABLES.ADA_GETA
  5415.                    (TABLE (IT).TABLE_STATUS.DESCR,
  5416.                     TABLE (IT).TABLE_DEFINITION.COLUMN_INDEX (IC), COMPONENT,
  5417.                     LENR, FTYP, RTN);
  5418.                 if RTN /= 0 then
  5419.                     UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5420.                     "internal error in GET_COLUMN");
  5421.                     raise X_INTERNAL_ERROR;
  5422.                 end if;
  5423.  
  5424.                 if TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC) /= null then
  5425.                     -- IC is of an enumeration type
  5426.  
  5427.                   begin
  5428.                     CHECKED := CONVERSION.ADA_ENUM (COMPONENT (1 ..
  5429.                           (TABLE(IT).TABLE_DEFINITION.COLUMN_LENGTH(IC) + 3)/4)
  5430.                              ,TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC));
  5431.                   exception
  5432.                     when X_INTERNAL_ERROR =>
  5433.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5434.                         "The value read from the database does not match "
  5435.                         & COLUMN_NAME & " type");
  5436.                         raise X_INVALID_VALUE;
  5437.                   end;
  5438.  
  5439.                     COMPONENT16 (1) := INTEGER16 (CHECKED);
  5440.  
  5441.                 elsif TABLE (IT).TABLE_DEFINITION.COLUMN_TYPES (IC) = 5 then
  5442.                     -- column of a character string type
  5443.                     USEFUL := (TABLE (IT).TABLE_DEFINITION.COLUMN_LENGTH (IC) +
  5444.                            3) / 4;
  5445.                     STRING_ITEM (1 .. 4 * USEFUL) :=
  5446.                       CONVERSION.ADA_STRING (COMPONENT (1 .. USEFUL), FALSE);
  5447.                     for I in 1 .. 4 * USEFUL loop
  5448.                         COMPONENT16 (I) := CHARACTER'POS (STRING_ITEM (I));
  5449.                     end loop;
  5450.                 else
  5451.                     -- INTEGER or FLOAT type
  5452.                     TEMP := CONVERSION.INTEGER_TO_TWO_WORDS (COMPONENT (1));
  5453.                     COMPONENT16 (1) := TEMP.WORD_1;
  5454.                     COMPONENT16 (2) := TEMP.WORD_2;
  5455.                     CHECKED := COMPONENT (1);
  5456.                 end if;
  5457.  
  5458.                 if TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC) /= null then
  5459.                         -- a range constraint applies to the column;the
  5460.                         -- value must be checked not to violate this range.
  5461.                     UTILITIES.CHECK_VALUE (CHECKED, IT, IC);
  5462.                 end if;
  5463.  
  5464.                 -- write the value of COMPONENT16 into ITEM_COPY
  5465.                 ADD_COMPONENT_TO_USER_COLUMN (ITEM_COPY, COMPONENT16, IT, IC,
  5466.                                                     CONVERSION.RECORD_COLUMN);
  5467.  
  5468.                 -- jump to the next column
  5469.                 exit when IC = TABLE (IT).TABLE_DEFINITION.COLUMN_NUMBER;
  5470.                 IC := IC + 1;
  5471.             end loop;
  5472.         else
  5473.             -- the column to be read is a scalar column
  5474.  
  5475.             -- first get into COMPONENT the actual value
  5476.             COMPONENT := (others => 0);
  5477.             F77_CALLABLES.ADA_GETA
  5478.                (TABLE (IT).TABLE_STATUS.DESCR,
  5479.                 TABLE (IT).TABLE_DEFINITION.COLUMN_INDEX (IC), COMPONENT,
  5480.                 LENR, FTYP, RTN);
  5481.             if RTN /= 0 then
  5482.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5483.                 "internal error in GET_COLUMN");
  5484.                 raise X_INTERNAL_ERROR;
  5485.             end if;
  5486.  
  5487.             if TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC) /= null then
  5488.                 -- IC is of an enumeration type
  5489.  
  5490.               begin
  5491.                 CHECKED := CONVERSION.ADA_ENUM (COMPONENT (1 ..
  5492.                       (TABLE(IT).TABLE_DEFINITION.COLUMN_LENGTH(IC) + 3)/4)
  5493.                          ,TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC));
  5494.               exception
  5495.                     when X_INTERNAL_ERROR =>
  5496.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5497.                         "The value read from the database does not match "
  5498.                         & COLUMN_NAME & " type");
  5499.                         raise X_INVALID_VALUE;
  5500.               end;
  5501.  
  5502.                 COMPONENT16 (1) := INTEGER16 (CHECKED);
  5503.  
  5504.             elsif TABLE (IT).TABLE_DEFINITION.COLUMN_TYPES (IC) = 5 then
  5505.                 -- column of a character string type
  5506.                 USEFUL := (TABLE (IT).TABLE_DEFINITION.COLUMN_LENGTH (IC) +
  5507.                        3) / 4;
  5508.                 STRING_ITEM (1 .. 4 * USEFUL) :=
  5509.                       CONVERSION.ADA_STRING (COMPONENT (1 .. USEFUL), FALSE);
  5510.                 for I in 1 .. 4 * USEFUL loop
  5511.                     COMPONENT16 (I) := CHARACTER'POS (STRING_ITEM (I));
  5512.                 end loop;
  5513.             else
  5514.                 -- INTEGER or FLOAT type
  5515.                 TEMP := CONVERSION.INTEGER_TO_TWO_WORDS (COMPONENT (1));
  5516.                 COMPONENT16 (1) := TEMP.WORD_1;
  5517.                 COMPONENT16 (2) := TEMP.WORD_2;
  5518.                 CHECKED := COMPONENT (1);
  5519.             end if;
  5520.  
  5521.             if TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC) /= null then
  5522.                     -- a range constraint applies to the column;the
  5523.                     -- value must be checked not to violate this range.
  5524.                 UTILITIES.CHECK_VALUE (CHECKED, IT, IC);
  5525.             end if;
  5526.  
  5527.             -- write the value of COMPONENT16 into ITEM_COPY
  5528.             ADD_COMPONENT_TO_USER_COLUMN (ITEM_COPY, COMPONENT16, IT, IC,
  5529.                                                 CONVERSION.SCALAR_COLUMN);
  5530.  
  5531.         end if;
  5532.  
  5533.         ITEM := ITEM_COPY;
  5534.     exception
  5535.         when CONSTRAINT_ERROR =>
  5536.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5537.             "The value read from the database does not match " & COLUMN_NAME
  5538.             & " type");
  5539.             raise X_INVALID_VALUE;
  5540.         -- CONSTRAINT_ERROR is raised in UNCHECKED_CONVERSION if the
  5541.         -- value of a column does not match its type
  5542.  
  5543.     end GET_COLUMN;
  5544.  
  5545.     procedure GET_ROW (TABLE_NAME : STRING; ITEM : out USER_ROW) is
  5546. --************************************************************************
  5547. --**                                                                    **
  5548. --**   UNIT NAME :          GET_ROW                                     **
  5549. --**   ~~~~~~~~~~~                                                      **
  5550. --** DESCRIPTION--------------------------------------------------------**
  5551. --**                                                                    **
  5552. --**                                                                    **
  5553. --**    if not A_DATABASE_IS_OPEN then                                  **
  5554. --**        raise X_TABLE_NOT_LOCKED;                                   **
  5555. --**    end if;                                                         **
  5556. --**                                                                    **
  5557. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  5558. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  5559. --**            -- array is 'unlocked'                                  **
  5560. --**        raise X_TABLE_NOT_LOCKED;                                   **
  5561. --**    end if;                                                         **
  5562. --**                                                                    **
  5563. --**    if THERE_IS_NO_CURRENT_ROW then                                 **
  5564. --**            -- the CURRENT_ROW component of TABLE_NAME in the TABLE **
  5565. --**            -- status array is 'init' or 'end'                      **
  5566. --**        raise X_NO_CURRENT_ROW;                                     **
  5567. --**    end if;                                                         **
  5568. --**                                                                    **
  5569. --**    if COLUMN_TYPE_DOES_NOT_MATCH_INSTANTIATION_TYPE then           **
  5570. --**            -- information known by DAMES about the type of the     **
  5571. --**            -- columns of the table does not match the USER_ROW     **
  5572. --**            -- type, which is defined when instantiating the        **
  5573. --**            -- generic GET_ROW procedure.                           **
  5574. --**        raise X_INVALID_COLUMN;                                     **
  5575. --**    end if;                                                         **
  5576. --**                                                                    **
  5577. --**    for COMPONENT in ROW_COMPONENTS loop                            **
  5578. --**                                                                    **
  5579. --**        GET_VALUE_FROM_DATABASE (COMPONENT);                        **
  5580. --**            -- the value is read in a fortran77 format and is       **
  5581. --**            -- contained in an array of 32-bit integers.            **
  5582. --**                                                                    **
  5583. --**        TRANSLATE_FROM_FORTRAN77_TO_ADA;                            **
  5584. --**            -- the value is translated from fortran77 format        **
  5585. --**            -- to ada format, and is stored  in  an  array  of      **
  5586. --**            -- 16-bit integers.                                     **
  5587. --**                                                                    **
  5588. --**        if COLUMN_TYPE_DOES_NOT_MATCH_COLUMN_VALUE then             **
  5589. --**            -- the type USER_ROW is then correct, but the           **
  5590. --**            -- value read from the table is not valid for the       **
  5591. --**            -- COMPONENT column type as described in the            **
  5592. --**            -- database                                             **
  5593. --**                                                                    **
  5594. --**        INSERT_VALUE_INTO_ITEM (COMPONENT);                         **
  5595. --**    end loop;                                                       **
  5596. --**                                                                    **
  5597. --** INPUT--------------------------------------------------------------**
  5598. --**                                                                    **
  5599. --**  TABLE_NAME : name of the table to be read.                        **
  5600. --**                                                                    **
  5601. --** STATUS VARIABLES USED----------------------------------------------**
  5602. --**                                                                    **
  5603. --**    A_DATABASE_IS_OPEN                                              **
  5604. --**    TABLE.LOCK                                                      **
  5605. --**                                                                    **
  5606. --** OUTPUT-------------------------------------------------------------**
  5607. --**                                                                    **
  5608. --**  ITEM  :  is the contents of the current row.                      **
  5609. --**                                                                    **
  5610. --** STATUS VARIABLES UPDATED-------------------------------------------**
  5611. --**                                                                    **
  5612. --**                                                                    **
  5613. --** EXCEPTIONS---------------------------------------------------------**
  5614. --**                                                                    **
  5615. --**    X_INVALID_VALUE                                                 **
  5616. --**    X_INVALID_COLUMN                                                **
  5617. --**    X_TABLE_NOT_LOCKED                                              **
  5618. --**    X_NO_CURRENT_ROW                                                **
  5619. --**                                                                    **
  5620. --************************************************************************
  5621.         USEFUL, IT, IC  : INTEGER;
  5622.         LENR, FTYP, RTN : INTEGER;
  5623.         CHECKED         : INTEGER;
  5624.         ITEM_COPY       : USER_ROW;
  5625.         STRING_ITEM : STRING (1 .. MAX_STRING);
  5626.         COMPONENT16 : INTEGER16_ARRAY_TYPE (1 .. MAX_STRING);
  5627.         COMPONENT   : INTEGER_ARRAY_TYPE (1 .. (3 + MAX_STRING) / 4);
  5628.         TEMP        : CONVERSION.TWO_WORDS;
  5629.         
  5630.         procedure ADD_COMPONENT_TO_USER_ROW is new
  5631.                 CONVERSION.ADD_COMPONENT (USER_ROW);
  5632.     begin
  5633.         if not SHARE.A_DATABASE_IS_OPEN then
  5634.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5635.             "A database must be opened and a table locked to use GET_ROW");
  5636.             raise X_TABLE_NOT_LOCKED;
  5637.         end if;
  5638.  
  5639.         -- get the index of the table or raise X_TABLE_NOT_LOCKED
  5640.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  5641.  
  5642.         if TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = -1 or
  5643.            TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = 0 then
  5644.             -- there is no currently selected row
  5645.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5646.             "A row must be selected by successfully using NEXT, PREVIOUS,");
  5647.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5648.             "FIND_NEXT or FIND_PREVIOUS before using GET_ROW");
  5649.             raise X_NO_CURRENT_ROW;
  5650.         end if;
  5651.  
  5652.         if USER_ROW'SIZE /= UTILITIES.TABLE_SIZE (IT) then
  5653.             -- the size of USER_ROW does not match the requested size
  5654.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5655.             "The size of the Ada type used to instantiate GET_ROW");
  5656.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5657.             "does not correspond to the size of the " & TABLE_NAME &
  5658.             " columns");
  5659.             raise X_INVALID_COLUMN;
  5660.         end if;
  5661.  
  5662.         IC := 1;
  5663.  
  5664.         while IC <= TABLE (IT).TABLE_DEFINITION.COLUMN_NUMBER loop
  5665.             -- loop for each column of the table
  5666.  
  5667.             COMPONENT := (others => 0);
  5668.  
  5669.             -- get the actual value of the ICth column into COMPONENT
  5670.             F77_CALLABLES.ADA_GETA
  5671.                (TABLE (IT).TABLE_STATUS.DESCR,
  5672.                 TABLE (IT).TABLE_DEFINITION.COLUMN_INDEX (IC), COMPONENT,
  5673.                 LENR, FTYP, RTN);
  5674.                 if RTN /= 0 then
  5675.                     UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5676.                     "internal error in GET_ROW");
  5677.                     raise X_INTERNAL_ERROR;
  5678.                 end if;
  5679.             if TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC) /= null then
  5680.                 -- column of an enumeration type
  5681.  
  5682.               begin
  5683.                 CHECKED := CONVERSION.ADA_ENUM (COMPONENT (1 ..
  5684.                           (TABLE(IT).TABLE_DEFINITION.COLUMN_LENGTH(IC) + 3)/4)
  5685.                              ,TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC));
  5686.               exception
  5687.                   when X_INTERNAL_ERROR =>
  5688.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5689.                         "The value read from the database does not match the table type");
  5690.                         raise X_INVALID_VALUE;
  5691.               end;
  5692.  
  5693.                 COMPONENT16 (1) := INTEGER16 (CHECKED);
  5694.  
  5695.             elsif TABLE (IT).TABLE_DEFINITION.COLUMN_TYPES (IC) = 5 then
  5696.                 -- column of a character string type
  5697.                 USEFUL := (TABLE (IT).TABLE_DEFINITION.COLUMN_LENGTH (IC) +
  5698.                            3) / 4;
  5699.                 STRING_ITEM (1 .. 4 * USEFUL) :=
  5700.                   CONVERSION.ADA_STRING (COMPONENT (1 .. USEFUL), FALSE);
  5701.                 for I in 1 .. 4 * USEFUL loop
  5702.                     COMPONENT16 (I) := CHARACTER'POS (STRING_ITEM (I));
  5703.                 end loop;
  5704.             else
  5705.                 -- INTEGER or FLOAT type
  5706.                 TEMP := CONVERSION.INTEGER_TO_TWO_WORDS (COMPONENT (1));
  5707.                 COMPONENT16 (1) := TEMP.WORD_1;
  5708.                 COMPONENT16 (2) := TEMP.WORD_2;
  5709.                 CHECKED := COMPONENT (1);
  5710.             end if;
  5711.  
  5712.             if TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC) /= null then
  5713.                     -- a range constraint applies to the column;the
  5714.                     -- value must be checked not to violate this range.
  5715.                 UTILITIES.CHECK_VALUE (CHECKED, IT, IC);
  5716.             end if;
  5717.  
  5718.             -- write bit by bit COMPONENT16 into a part of ITEM_COPY
  5719.             ADD_COMPONENT_TO_USER_ROW (ITEM_COPY, COMPONENT16, IT, IC,
  5720.                                                 CONVERSION.WHOLE_TABLE);
  5721.             IC := IC + 1;
  5722.         end loop;
  5723.  
  5724.         ITEM := ITEM_COPY;
  5725.  
  5726.     exception
  5727.         when CONSTRAINT_ERROR =>
  5728.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5729.             "The values read from the database do not match " & TABLE_NAME
  5730.             & " columns types");
  5731.             raise X_INVALID_VALUE;
  5732.         -- CONSTRAINT_ERROR is raised in UNCHECKED_CONVERSION if the
  5733.         -- value of a column does not match its type
  5734.  
  5735.     end GET_ROW;
  5736.     procedure BUILD_COLUMN (TABLE_NAME  : STRING;
  5737.                             COLUMN_NAME : STRING;
  5738.                             ITEM        : USER_COLUMN) is
  5739. --************************************************************************
  5740. --**                                                                    **
  5741. --**   UNIT NAME :          BUILD_COLUMN                                **
  5742. --**   ~~~~~~~~~~~                                                      **
  5743. --** DESCRIPTION--------------------------------------------------------**
  5744. --**                                                                    **
  5745. --**                                                                    **
  5746. --**    if not A_DATABASE_IS_OPEN then                                  **
  5747. --**        raise X_TABLE_NOT_LOCKED;                                   **
  5748. --**    end if;                                                         **
  5749. --**                                                                    **
  5750. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  5751. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  5752. --**            -- array is 'unlocked'                                  **
  5753. --**        raise X_TABLE_NOT_LOCKED;                                   **
  5754. --**    end if;                                                         **
  5755. --**                                                                    **
  5756. --**    if TABLE_NAME_IS_LOCKED_IN_SHARED_MODE then                     **
  5757. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  5758. --**            -- array is 'shared'                                    **
  5759. --**        raise X_SHARED_MODE_LOCK;                                   **
  5760. --**    end if;                                                         **
  5761. --**                                                                    **
  5762. --**    if COLUMN_NAME_DOES_NOT_EXIST then                              **
  5763. --**            -- COLUMN_NAME is not the name of one of the columns    **
  5764. --**            -- of the TABLE_NAME table                              **
  5765. --**        raise X_INVALID_COLUMN;                                     **
  5766. --**    end if;                                                         **
  5767. --**                                                                    **
  5768. --**    if COLUMN_TYPE_DOES_NOT_MATCH_INSTANTIATION_TYPE then           **
  5769. --**            -- information known by DAMES about the type of the     **
  5770. --**            -- COLUMN_NAME column does not match the USER_COLUMN    **
  5771. --**            -- type, which is defined when instantiating the        **
  5772. --**            -- generic BUILD_COLUMN procedure.                      **
  5773. --**        raise X_INVALID_COLUMN;                                     **
  5774. --**    end if;                                                         **
  5775. --**                                                                    **
  5776. --**    if COLUMN_TYPE_IS_RECORD then                                   **
  5777. --**                                                                    **
  5778. --**        for COMPONENT in COLUMN_COMPONENTS loop                     **
  5779. --**                                                                    **
  5780. --**            EXTRACT_VALUE_FROM_ITEM (COMPONENT);                    **
  5781. --**                -- the extracted value is stored  in  an  array  of **
  5782. --**                -- 16-bit integers.                                 **
  5783. --**                                                                    **
  5784. --**            TRANSLATE_FROM_ADA_TO_FORTRAN77_FORMAT;                 **
  5785. --**                -- the value is translated from ada  format  to     **
  5786. --**                -- fortran77 format, and is stored  in  an array of **
  5787. --**                -- 32-bit integers.                                 **
  5788. --**                                                                    **
  5789. --**            if COLUMN_TYPE_DOES_NOT_MATCH_COLUMN_VALUE then         **
  5790. --**                -- the type USER_COLUMN  is  correct, but the value **
  5791. --**                -- to be written into the table is not valid for the**
  5792. --**                -- COMPONENT column type as described in the        **
  5793. --**                -- database                                         **
  5794. --**                                                                    **
  5795. --**            PUT_VALUE_INTO_DATABASE (COMPONENT);                    **
  5796. --**        end loop;                                                   **
  5797. --**    else    -- the COLUMN_NAME column is of a scalar type           **
  5798. --**                                                                    **
  5799. --**        COPY_VALUE_FROM_ITEM (COLUMN_NAME);                         **
  5800. --**            -- the value of ITEM is copied into an array of         **
  5801. --**            -- 16-bit integers.                                     **
  5802. --**                                                                    **
  5803. --**        TRANSLATE_FROM_ADA_TO_FORTRAN77;                            **
  5804. --**            -- the  value  is  translated  from  ada  format  to    **
  5805. --**            -- fortran77 format, and is stored in an array of       **
  5806. --**            -- 32-bit integers.                                     **
  5807. --**                                                                    **
  5808. --**        if COLUMN_TYPE_DOES_NOT_MATCH_COLUMN_VALUE then             **
  5809. --**            -- the type USER_COLUMN is then correct, but the value  **
  5810. --**            -- to be written into the table is not valid for the    **
  5811. --**            -- COLUMN_NAME column type as described in the          **
  5812. --**            -- database                                             **
  5813. --**                                                                    **
  5814. --**        PUT_VALUE_INTO_DATABASE (COLUMN_NAME);                      **
  5815. --**                                                                    **
  5816. --**    end if;                                                         **
  5817. --**                                                                    **
  5818. --**                                                                    **
  5819. --** INPUT--------------------------------------------------------------**
  5820. --**                                                                    **
  5821. --**  TABLE_NAME : name of the table to be processed.                   **
  5822. --**  COLUMN_NAME : name  of  the  column  in  the temporary which will **
  5823. --**  be written; its type must be USER_COLUMN.                         **
  5824. --**  ITEM   :   value   to   be  copied  into  the   temporary   row.  **
  5825. --**                                                                    **
  5826. --** STATUS VARIABLES USED----------------------------------------------**
  5827. --**                                                                    **
  5828. --**    A_DATABASE_IS_OPEN                                              **
  5829. --**    TABLE.LOCK                                                      **
  5830. --**                                                                    **
  5831. --** OUTPUT-------------------------------------------------------------**
  5832. --**                                                                    **
  5833. --**                                                                    **
  5834. --** STATUS VARIABLES UPDATED-------------------------------------------**
  5835. --**                                                                    **
  5836. --**                                                                    **
  5837. --** EXCEPTIONS---------------------------------------------------------**
  5838. --**                                                                    **
  5839. --**    X_TABLE_NOT_LOCKED                                              **
  5840. --**    X_INVALID_COLUMN                                                **
  5841. --**    X_INVALID_VALUE                                                 **
  5842. --**    X_SHARED_MODE_LOCK                                              **
  5843. --**                                                                    **
  5844. --************************************************************************
  5845.         USEFUL, IT, IC : INTEGER;
  5846.         RTN            : INTEGER;
  5847.         CHECKED        : INTEGER;
  5848.         IS_RECORD      : BOOLEAN;
  5849.         RECORD_NAME    : STRING (1 .. NAME_LENGTH);
  5850.         STRING_ITEM : STRING (1 .. MAX_STRING);
  5851.         COMPONENT   : INTEGER_ARRAY_TYPE (1 .. (3 + MAX_STRING) / 4);
  5852.         COMPONENT16 : INTEGER16_ARRAY_TYPE (1 .. MAX_STRING);
  5853.         TEMP        : CONVERSION.TWO_WORDS;
  5854.  
  5855.         procedure GET_COMPONENT_FROM_USER_COLUMN is new
  5856.                             CONVERSION.GET_COMPONENT (USER_COLUMN);
  5857.     begin
  5858.         if not SHARE.A_DATABASE_IS_OPEN then
  5859.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5860.             "A database must be opened to use BUILD_COLUMN");
  5861.             raise X_TABLE_NOT_LOCKED;
  5862.         end if;
  5863.  
  5864.         -- get the index of the table or raise X_TABLE_NOT_LOCKED
  5865.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  5866.  
  5867.         if TABLE (IT).TABLE_STATUS.CURRENT_LOCK = SHARED then
  5868.             -- the table should be locked in exclusive mode
  5869.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5870.             "BUILD_COLUMN cannot be applied to a table locked in shared");
  5871.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5872.             "mode; it must be in exclusive mode");
  5873.             raise X_SHARED_MODE_LOCK;
  5874.         end if;
  5875.  
  5876.         -- get the index of COLUMN_NAME into IC and set IS_RECORD to 
  5877.         -- 'false' if a scalar column has been found, and 'true' if this
  5878.         -- is only a record column.
  5879.         -- X_INVALID_COLUMN is raised if no column has been found with the
  5880.         -- name COLUMN_NAME
  5881.         UTILITIES.COLUMN (IT, COLUMN_NAME, IC, IS_RECORD);
  5882.  
  5883.         if USER_COLUMN'SIZE /=
  5884.            UTILITIES.RECORD_BIT_SIZE (IT, IC, IS_RECORD) then
  5885.             -- the size of USER_COLUMN does not match the requested size
  5886.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5887.             "The size of the Ada type used to instantiate BUILD_COLUMN");
  5888.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5889.             "does not correspond to the size of the " & COLUMN_NAME &
  5890.             " column");
  5891.             raise X_INVALID_COLUMN;
  5892.         end if;
  5893.  
  5894.         if IS_RECORD then
  5895.             -- COLUMN_NAME is a record column
  5896.             RECORD_NAME := TABLE (IT).TABLE_DEFINITION.IN_RECORD (IC);
  5897.  
  5898.             while TABLE (IT).TABLE_DEFINITION.IN_RECORD (IC) = RECORD_NAME loop
  5899.                 -- loop for each component of the record column
  5900.  
  5901.                 COMPONENT := (others => 0);
  5902.                 -- get the actual value of the ICth component of ITEM
  5903.                 -- into COMPONENT16
  5904.                 GET_COMPONENT_FROM_USER_COLUMN (ITEM, COMPONENT16, IT, IC,
  5905.                                                    CONVERSION.RECORD_COLUMN);
  5906.  
  5907.                 if TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC) /= null then
  5908.                         -- the ICth column is of an enumeration type
  5909.                     COMPONENT (1 .. (3 + IMAGE_SZ) / 4) :=
  5910.                       CONVERSION.F77_ENUM
  5911.                          (INTEGER (COMPONENT16 (1)),
  5912.                         TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC));
  5913.                     CHECKED := INTEGER (COMPONENT16 (1));
  5914.  
  5915.                 elsif TABLE (IT).TABLE_DEFINITION.COLUMN_TYPES (IC) = 5 then
  5916.                         -- the ICth column is of a character string
  5917.                     USEFUL := TABLE (IT).TABLE_DEFINITION.COLUMN_LENGTH(IC);
  5918.                     for I in 1 .. USEFUL loop
  5919.                         STRING_ITEM (I) := CHARACTER'VAL (COMPONENT16 (I));
  5920.                     end loop;
  5921.                     COMPONENT (1 .. (3 + USEFUL) / 4) :=
  5922.                       CONVERSION.F77_STRING (STRING_ITEM (1 .. USEFUL));
  5923.                 else
  5924.                         -- the ICth column is of an INTEGER or of a FLOAT type
  5925.                     TEMP.WORD_1 := COMPONENT16 (1);
  5926.                     TEMP.WORD_2 := COMPONENT16 (2);
  5927.                     COMPONENT (1) := CONVERSION.TWO_WORDS_TO_INTEGER (TEMP);
  5928.                     CHECKED := COMPONENT (1);
  5929.                 end if;
  5930.  
  5931.                 if TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC) /= null then
  5932.                         -- a range constraint applies to the column;the
  5933.                         -- value must be checked not to violate this range.
  5934.                     UTILITIES.CHECK_VALUE (CHECKED, IT, IC);
  5935.                 end if;
  5936.  
  5937.                 -- write COMPONENT into the table
  5938.                 F77_CALLABLES.ADA_PUTA
  5939.                    (TABLE (IT).TABLE_STATUS.DESCR,
  5940.                     TABLE (IT).TABLE_DEFINITION.COLUMN_INDEX (IC), COMPONENT,
  5941.                     -1, RTN);
  5942.                 if RTN /= 0 then
  5943.                     UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5944.                     "internal error in BUILD_COLUMN");
  5945.                     raise X_INTERNAL_ERROR;
  5946.                 end if;
  5947.  
  5948.                 exit when IC = TABLE (IT).TABLE_DEFINITION.COLUMN_NUMBER;
  5949.                 IC := IC + 1;
  5950.             end loop;
  5951.         else
  5952.                 -- the column to be written is a scalar one
  5953.  
  5954.                 COMPONENT := (others => 0);
  5955.  
  5956.                 -- copy the actual value of ITEM into COMPONENT16
  5957.                 GET_COMPONENT_FROM_USER_COLUMN (ITEM, COMPONENT16, IT, IC,
  5958.                                                    CONVERSION.SCALAR_COLUMN);
  5959.             if TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC) /= null then
  5960.                     -- the ICth column is of an enumeration type
  5961.                 COMPONENT (1 .. (3 + IMAGE_SZ) / 4) :=
  5962.                   CONVERSION.F77_ENUM
  5963.                      (INTEGER (COMPONENT16 (1)),
  5964.                 TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC));
  5965.                 CHECKED := INTEGER (COMPONENT16 (1));
  5966.  
  5967.             elsif TABLE (IT).TABLE_DEFINITION.COLUMN_TYPES (IC) = 5 then
  5968.                     -- the ICth column is of a character string
  5969.                 USEFUL := TABLE (IT).TABLE_DEFINITION.COLUMN_LENGTH(IC);
  5970.                 for I in 1 .. USEFUL loop
  5971.                     STRING_ITEM (I) := CHARACTER'VAL (COMPONENT16 (I));
  5972.                 end loop;
  5973.                 COMPONENT (1 .. (3 + USEFUL) / 4) :=
  5974.                   CONVERSION.F77_STRING (STRING_ITEM (1 .. USEFUL));
  5975.             else
  5976.                     -- the ICth column is of an INTEGER or of a FLOAT type
  5977.                 TEMP.WORD_1 := COMPONENT16 (1);
  5978.                 TEMP.WORD_2 := COMPONENT16 (2);
  5979.                 COMPONENT (1) := CONVERSION.TWO_WORDS_TO_INTEGER (TEMP);
  5980.                 CHECKED := COMPONENT (1);
  5981.             end if;
  5982.  
  5983.             if TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC) /= null then
  5984.                     -- a range constraint applies to the column;the
  5985.                     -- value must be checked not to violate this range.
  5986.                 UTILITIES.CHECK_VALUE (CHECKED, IT, IC);
  5987.             end if;
  5988.  
  5989.             -- put COMPONENT into the table
  5990.             F77_CALLABLES.ADA_PUTA
  5991.                (TABLE (IT).TABLE_STATUS.DESCR,
  5992.                 TABLE (IT).TABLE_DEFINITION.COLUMN_INDEX (IC), COMPONENT, -1,
  5993.                 RTN);
  5994.             if RTN /= 0 then
  5995.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  5996.                 "internal error in BUILD_COLUMN");
  5997.                 raise X_INTERNAL_ERROR;
  5998.             end if;
  5999.         end if;
  6000.  
  6001.     end BUILD_COLUMN;
  6002.     procedure BUILD_ROW (TABLE_NAME : STRING; ITEM : USER_ROW) is
  6003. --************************************************************************
  6004. --**                                                                    **
  6005. --**   UNIT NAME :          BUILD_ROW                                   **
  6006. --**   ~~~~~~~~~~~                                                      **
  6007. --** DESCRIPTION--------------------------------------------------------**
  6008. --**                                                                    **
  6009. --**                                                                    **
  6010. --**    if not A_DATABASE_IS_OPEN then                                  **
  6011. --**        raise X_TABLE_NOT_LOCKED;                                   **
  6012. --**    end if;                                                         **
  6013. --**                                                                    **
  6014. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  6015. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  6016. --**            -- array is 'unlocked'                                  **
  6017. --**        raise X_TABLE_NOT_LOCKED;                                   **
  6018. --**    end if;                                                         **
  6019. --**                                                                    **
  6020. --**    if TABLE_NAME_IS_LOCKED_IN_SHARED_MODE then                     **
  6021. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  6022. --**            -- array is 'shared'                                    **
  6023. --**        raise X_SHARED_MODE_LOCK;                                   **
  6024. --**    end if;                                                         **
  6025. --**                                                                    **
  6026. --**    if COLUMN_TYPE_DOES_NOT_MATCH_INSTANTIATION_TYPE then           **
  6027. --**            -- information known by DAMES about the types of the    **
  6028. --**            -- columns of the table does not match the USER_ROW     **
  6029. --**            -- type, which is defined when instantiating the        **
  6030. --**            -- generic BUILD_ROW procedure.                         **
  6031. --**        raise X_INVALID_COLUMN;                                     **
  6032. --**    end if;                                                         **
  6033. --**                                                                    **
  6034. --**    for COMPONENT in ROW_COMPONENTS loop                            **
  6035. --**                                                                    **
  6036. --**        EXTRACT_VALUE_FROM_ITEM (COMPONENT);                        **
  6037. --**            -- the extracted value is stored in an array of 16-bit  **
  6038. --**            -- integers.                                            **
  6039. --**                                                                    **
  6040. --**        TRANSLATE_FROM_ADA_TO_FORTRAN77;                            **
  6041. --**            -- the value  is  translated  from  ada  format  to     **
  6042. --**            -- fortran77 format, and is stored  in  an  array of    **
  6043. --**            -- 32-bit integers.                                     **
  6044. --**                                                                    **
  6045. --**        if COLUMN_TYPE_DOES_NOT_MATCH_COLUMN_VALUE then             **
  6046. --**            -- the type USER_ROW is then correct, but the           **
  6047. --**            -- value read from the table is not valid for the       **
  6048. --**            -- COMPONENT column type as described in the            **
  6049. --**            -- database                                             **
  6050. --**                                                                    **
  6051. --**        PUT_VALUE_INTO_DATABASE (COMPONENT);                        **
  6052. --**                                                                    **
  6053. --**    end loop;                                                       **
  6054. --**                                                                    **
  6055. --**                                                                    **
  6056. --** INPUT--------------------------------------------------------------**
  6057. --**                                                                    **
  6058. --**  TABLE_NAME : name of the table to be processed.                   **
  6059. --**  ITEM   :   value   to   be  copied  into  the   temporary   row.  **
  6060. --**                                                                    **
  6061. --** STATUS VARIABLES USED----------------------------------------------**
  6062. --**                                                                    **
  6063. --**    A_DATABASE_IS_OPEN                                              **
  6064. --**    TABLE.LOCK                                                      **
  6065. --**                                                                    **
  6066. --** OUTPUT-------------------------------------------------------------**
  6067. --**                                                                    **
  6068. --**                                                                    **
  6069. --** STATUS VARIABLES UPDATED-------------------------------------------**
  6070. --**                                                                    **
  6071. --**                                                                    **
  6072. --** EXCEPTIONS---------------------------------------------------------**
  6073. --**                                                                    **
  6074. --**    X_TABLE_NOT_LOCKED                                              **
  6075. --**    X_INVALID_VALUE                                                 **
  6076. --**    X_INVALID_COLUMN                                                **
  6077. --**    X_SHARED_MODE_LOCK                                              **
  6078. --**                                                                    **
  6079. --************************************************************************
  6080.         USEFUL, IT, IC : INTEGER;
  6081.         RTN            : INTEGER;
  6082.         CHECKED        : INTEGER;
  6083.         STRING_ITEM : STRING (1 .. MAX_STRING);
  6084.         COMPONENT   : INTEGER_ARRAY_TYPE (1 .. (3 + MAX_STRING) / 4);
  6085.         COMPONENT16 : INTEGER16_ARRAY_TYPE (1 .. MAX_STRING);
  6086.         TEMP        : CONVERSION.TWO_WORDS;
  6087.  
  6088.         procedure GET_COMPONENT_FROM_USER_ROW is new
  6089.                             CONVERSION.GET_COMPONENT (USER_ROW);
  6090.     begin
  6091.         if not SHARE.A_DATABASE_IS_OPEN then
  6092.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6093.             "A database must be opened and a table locked to use BUILD_ROW");
  6094.             raise X_TABLE_NOT_LOCKED;
  6095.         end if;
  6096.  
  6097.         -- get the index of TABLE_NAME or raise X_TABLE_NOT_LOCKED
  6098.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  6099.  
  6100.         if TABLE (IT).TABLE_STATUS.CURRENT_LOCK = SHARED then
  6101.             -- the table should have been locked in exclusive mode
  6102.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6103.             "BUILD_ROW cannot be applied to a table locked in shared");
  6104.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6105.             "mode; it must be in exclusive mode");
  6106.             raise X_SHARED_MODE_LOCK;
  6107.         end if;
  6108.  
  6109.         if USER_ROW'SIZE /= UTILITIES.TABLE_SIZE (IT) then
  6110.             -- the USER_ROW size does not match the requested size
  6111.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6112.             "The size of the Ada type used to instantiate BUILD_ROW");
  6113.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6114.             "does not correspond to the size of the " & TABLE_NAME &
  6115.             " columns");
  6116.             raise X_INVALID_COLUMN;
  6117.         end if;
  6118.  
  6119.         IC := 1;
  6120.  
  6121.         while IC <= TABLE (IT).TABLE_DEFINITION.COLUMN_NUMBER loop
  6122.             -- loop for each column of the table
  6123.  
  6124.             COMPONENT := (others => 0);
  6125.  
  6126.             -- get into COMPONENT16 the ICth component of the ITEM
  6127.             -- record value
  6128.             GET_COMPONENT_FROM_USER_ROW (ITEM, COMPONENT16, IT, IC,
  6129.                                                 CONVERSION.WHOLE_TABLE);
  6130.  
  6131.             if TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC) /= null then
  6132.                 -- the ICth column is of an enumeration type
  6133.                 COMPONENT (1 .. (3 + IMAGE_SZ) / 4) :=
  6134.                   CONVERSION.F77_ENUM
  6135.                      (INTEGER (COMPONENT16 (1)),
  6136.                       TABLE (IT).TABLE_DEFINITION.ENUM_TYPES (IC));
  6137.                 CHECKED := INTEGER (COMPONENT16 (1));
  6138.             elsif TABLE (IT).TABLE_DEFINITION.COLUMN_TYPES (IC) = 5 then
  6139.                 -- the ICth column is of a character string
  6140.                 USEFUL := TABLE (IT).TABLE_DEFINITION.COLUMN_LENGTH (IC);
  6141.                 for I in 1 .. USEFUL loop
  6142.                     STRING_ITEM (I) := CHARACTER'VAL (COMPONENT16 (I));
  6143.                 end loop;
  6144.                 COMPONENT (1 .. (3 + USEFUL) / 4) :=
  6145.                   CONVERSION.F77_STRING (STRING_ITEM (1 .. USEFUL));
  6146.             else
  6147.                 -- the ICth column is of an INTEGER or of a FLOAT type
  6148.                 TEMP.WORD_1 := COMPONENT16 (1);
  6149.                 TEMP.WORD_2 := COMPONENT16 (2);
  6150.                 COMPONENT (1) := CONVERSION.TWO_WORDS_TO_INTEGER (TEMP);
  6151.                 CHECKED := COMPONENT (1);
  6152.             end if;
  6153.  
  6154.             if TABLE (IT).TABLE_DEFINITION.CONSTRAINTS (IC) /= null then
  6155.                     -- a range constraint applies to the column;the
  6156.                     -- value must be checked not to violate this range.
  6157.                 UTILITIES.CHECK_VALUE (CHECKED, IT, IC);
  6158.             end if;
  6159.  
  6160.             -- put COMPONENT into the corresponding place in the current
  6161.             -- row
  6162.             F77_CALLABLES.ADA_PUTA
  6163.                (TABLE (IT).TABLE_STATUS.DESCR,
  6164.                 TABLE (IT).TABLE_DEFINITION.COLUMN_INDEX (IC), COMPONENT, -1,
  6165.                 RTN);
  6166.             if RTN /= 0 then
  6167.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6168.                 "internal error in BUILD_ROW");
  6169.                 raise X_INTERNAL_ERROR;
  6170.             end if;
  6171.  
  6172.             IC := IC + 1;
  6173.         end loop;
  6174.     end BUILD_ROW;
  6175.  
  6176.  
  6177.     procedure UPDATE (TABLE_NAME : STRING) is
  6178. --************************************************************************
  6179. --**                                                                    **
  6180. --**   UNIT NAME :          UPDATE                                      **
  6181. --**   ~~~~~~~~~~~                                                      **
  6182. --** DESCRIPTION--------------------------------------------------------**
  6183. --**                                                                    **
  6184. --**                                                                    **
  6185. --**    if not A_DATABASE_IS_OPEN then                                  **
  6186. --**        raise X_TABLE_NOT_LOCKED;                                   **
  6187. --**    end if;                                                         **
  6188. --**                                                                    **
  6189. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  6190. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  6191. --**            -- array is 'unlocked'                                  **
  6192. --**        raise X_TABLE_NOT_LOCKED;                                   **
  6193. --**    end if;                                                         **
  6194. --**                                                                    **
  6195. --**    if TABLE_NAME_IS_LOCKED_IN_SHARED_MODE then                     **
  6196. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  6197. --**            -- array is 'shared'                                    **
  6198. --**        raise X_SHARED_MODE_LOCK;                                   **
  6199. --**    end if;                                                         **
  6200. --**                                                                    **
  6201. --**    if THERE_IS_NO_CURRENT_ROW then                                 **
  6202. --**            -- the CURRENT_ROW component of TABLE_NAME in the TABLE **
  6203. --**            -- status array is 'init' or 'end'                      **
  6204. --**        raise X_NO_CURRENT_ROW;                                     **
  6205. --**    end if;                                                         **
  6206. --**                                                                    **
  6207. --**    if TABLE_IS_SORTED then                                         **
  6208. --**                                                                    **
  6209. --**            -- i.e. when the table is  sorted, and would be         **
  6210. --**            -- disordered by replacing the current row with         **
  6211. --**            -- the temporary one                                    **
  6212. --**        DELETE_CURRENT_ROW;                                         **
  6213. --**        INSERT_TEMPORARY_ROW_SO_THAT_TABLE_REMAINS_SORTED;          **
  6214. --**                                                                    **
  6215. --**    else                                                            **
  6216. --**            -- i.e. when the table is not sorted                    **
  6217. --**        REPLACE_CURRENT_ROW_WITH_TEMPORARY_ROW;                     ** 
  6218. --**    end if;                                                         **
  6219. --**                                                                    **
  6220. --**                                                                    **
  6221. --** INPUT--------------------------------------------------------------**
  6222. --**                                                                    **
  6223. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  6224. --**                                                                    **
  6225. --** STATUS VARIABLES USED----------------------------------------------**
  6226. --**                                                                    **
  6227. --**    A_DATABASE_IS_OPEN                                              **
  6228. --**    TABLE.LOCK                                                      **
  6229. --**                                                                    **
  6230. --** OUTPUT-------------------------------------------------------------**
  6231. --**                                                                    **
  6232. --**                                                                    **
  6233. --** STATUS VARIABLES UPDATED-------------------------------------------**
  6234. --**                                                                    **
  6235. --**                                                                    **
  6236. --** EXCEPTIONS---------------------------------------------------------**
  6237. --**                                                                    **
  6238. --**    X_TABLE_NOT_LOCKED                                              **
  6239. --**    X_NO_CURRENT_ROW                                                **
  6240. --**    X_SHARED_MODE_LOCK                                              **
  6241. --**                                                                    **
  6242. --************************************************************************
  6243.  
  6244.         IT, RTN : INTEGER;
  6245.     begin
  6246.         if not SHARE.A_DATABASE_IS_OPEN then
  6247.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6248.             "A database must be opened and a table locked to use UPDATE");
  6249.             raise X_TABLE_NOT_LOCKED;
  6250.         end if;
  6251.  
  6252.         -- get the index of the table or raise X_TABLE_NOT_LOCKED
  6253.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  6254.  
  6255.         if TABLE (IT).TABLE_STATUS.CURRENT_LOCK = SHARED then
  6256.             -- the table should have been locked in exclusive mode
  6257.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6258.             "UPDATE cannot be applied to a table locked in shared");
  6259.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6260.             "mode; it must be in exclusive mode");
  6261.             raise X_SHARED_MODE_LOCK;
  6262.         end if;
  6263.  
  6264.         if TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = 0 or
  6265.            TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = -1 then
  6266.             -- no row is currently selected
  6267.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6268.             "A row must be selected by successfully using NEXT, PREVIOUS,");
  6269.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6270.             "FIND_NEXT or FIND_PREVIOUS before using UPDATE");
  6271.             raise X_NO_CURRENT_ROW;
  6272.         end if;
  6273.  
  6274.         if TABLE (IT).TABLE_DEFINITION.SORTED then
  6275.             -- the table is sorted
  6276.  
  6277.             -- first delete the current row
  6278.             F77_CALLABLES.ADA_DELETT
  6279.                (TABLE (IT).TABLE_STATUS.DESCR,
  6280.                 TABLE (IT).TABLE_STATUS.CURRENT_ROW, RTN);
  6281.             if RTN /= 0 then
  6282.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6283.                 "internal error when deleting the old row in UPDATE");
  6284.                 raise X_INTERNAL_ERROR;
  6285.             end if;
  6286.  
  6287.             -- ... and then insert the temporary row so that the table
  6288.             -- remains sorted
  6289.             SORTED_INSERT (IT);
  6290.         else
  6291.             -- the table is not sorted
  6292.  
  6293.             -- replace the current row with the temporary one
  6294.             F77_CALLABLES.ADA_REPLAT
  6295.                (TABLE (IT).TABLE_STATUS.DESCR,
  6296.                 TABLE (IT).TABLE_STATUS.CURRENT_ROW, RTN);
  6297.             if RTN /= 0 then
  6298.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6299.                 "internal error when updating the old row in UPDATE");
  6300.                 raise X_INTERNAL_ERROR;
  6301.             end if;
  6302.         end if;
  6303.     end UPDATE;
  6304.  
  6305.     procedure INSERT (TABLE_NAME : STRING) is
  6306. --************************************************************************
  6307. --**                                                                    **
  6308. --**   UNIT NAME :          INSERT                                      **
  6309. --**   ~~~~~~~~~~~                                                      **
  6310. --** DESCRIPTION--------------------------------------------------------**
  6311. --**                                                                    **
  6312. --**                                                                    **
  6313. --**    if not A_DATABASE_IS_OPEN then                                  **
  6314. --**        raise X_TABLE_NOT_LOCKED;                                   **
  6315. --**    end if;                                                         **
  6316. --**                                                                    **
  6317. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  6318. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  6319. --**            -- array is 'unlocked'                                  **
  6320. --**        raise X_TABLE_NOT_LOCKED;                                   **
  6321. --**    end if;                                                         **
  6322. --**                                                                    **
  6323. --**    if TABLE_NAME_IS_LOCKED_IN_SHARED_MODE then                     **
  6324. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  6325. --**            -- array is 'shared'                                    **
  6326. --**        raise X_SHARED_MODE_LOCK;                                   **
  6327. --**    end if;                                                         **
  6328. --**                                                                    **
  6329. --**    if TABLE_IS_SORTED then                                         **
  6330. --**        INSERT_TEMPORARY_ROW_SO_THAT_TABLE_REMAINS_SORTED;          ** 
  6331. --**                                                                    **
  6332. --**    else                                                            **
  6333. --**        APPEND_TEMPORARY_ROW;                                       **
  6334. --**    end if;                                                         **
  6335. --**                                                                    **
  6336. --**    if ERROR then                                                   **
  6337. --**        raise X_FULL_TABLE;                                         **
  6338. --**    end if;                                                         **
  6339. --**                                                                    **
  6340. --**                                                                    **
  6341. --** INPUT--------------------------------------------------------------**
  6342. --**                                                                    **
  6343. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  6344. --**                                                                    **
  6345. --** STATUS VARIABLES USED----------------------------------------------**
  6346. --**                                                                    **
  6347. --**    A_DATABASE_IS_OPEN                                              **
  6348. --**    TABLE.LOCK                                                      **
  6349. --**                                                                    **
  6350. --** OUTPUT-------------------------------------------------------------**
  6351. --**                                                                    **
  6352. --**                                                                    **
  6353. --** STATUS VARIABLES UPDATED-------------------------------------------**
  6354. --**                                                                    **
  6355. --**                                                                    **
  6356. --** EXCEPTIONS---------------------------------------------------------**
  6357. --**                                                                    **
  6358. --**    X_TABLE_NOT_LOCKED                                              **
  6359. --**    X_FULL_TABLE                                                    **
  6360. --**    X_SHARED_MODE_LOCK                                              **
  6361. --**                                                                    **
  6362. --************************************************************************
  6363.         IT, RTN : INTEGER;
  6364.     begin
  6365.         if not SHARE.A_DATABASE_IS_OPEN then
  6366.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6367.             "A database must be opened and a table locked to use INSERT");
  6368.             raise X_TABLE_NOT_LOCKED;
  6369.         end if;
  6370.  
  6371.         -- get the index of the table or raise X_TABLE_NOT_LOCKED
  6372.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  6373.  
  6374.         if TABLE (IT).TABLE_STATUS.CURRENT_LOCK = SHARED then
  6375.             -- the table should have been locked in exclusive mode
  6376.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6377.             "INSERT cannot be applied to a table locked in shared");
  6378.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6379.             "mode; it must be in exclusive mode");
  6380.             raise X_SHARED_MODE_LOCK;
  6381.         end if;
  6382.  
  6383.         if TABLE (IT).TABLE_DEFINITION.SORTED then
  6384.             -- the table is sorted
  6385.  
  6386.             -- insert the temporary row sothat the table remains sorted
  6387.             SORTED_INSERT (IT);
  6388.             RTN := 0;
  6389.         else
  6390.             -- the table is not sorted
  6391.  
  6392.             -- insert the temporary row at the current position
  6393.             F77_CALLABLES.ADA_INSRTT
  6394.                (TABLE (IT).TABLE_STATUS.DESCR,
  6395.                 TABLE (IT).TABLE_STATUS.CURRENT_ROW, RTN);
  6396.         end if;
  6397.  
  6398.         if RTN /= 0 then
  6399.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6400.             "No other row can be added to the " & TABLE_NAME &
  6401.             " table; it is full");
  6402.             raise X_FULL_TABLE;
  6403.         end if;
  6404.     end INSERT;
  6405.  
  6406.     procedure DELETE (TABLE_NAME : STRING; NO_MORE_ROW : out BOOLEAN) is
  6407. --************************************************************************
  6408. --**                                                                    **
  6409. --**   UNIT NAME :          DELETE                                      **
  6410. --**   ~~~~~~~~~~~                                                      **
  6411. --** DESCRIPTION--------------------------------------------------------**
  6412. --**                                                                    **
  6413. --**                                                                    **
  6414. --**    if not A_DATABASE_IS_OPEN then                                  **
  6415. --**        raise X_TABLE_NOT_LOCKED;                                   **
  6416. --**    end if;                                                         **
  6417. --**                                                                    **
  6418. --**    if TABLE_NAME_IS_UNLOCKED then                                  **
  6419. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  6420. --**            -- array is 'unlocked'                                  **
  6421. --**        raise X_TABLE_NOT_LOCKED;                                   **
  6422. --**    end if;                                                         **
  6423. --**                                                                    **
  6424. --**    if TABLE_NAME_IS_LOCKED_IN_SHARED_MODE then                     **
  6425. --**            -- the LOCK component of TABLE_NAME in the TABLE status **
  6426. --**            -- array is 'shared'                                    **
  6427. --**        raise X_SHARED_MODE_LOCK;                                   **
  6428. --**    end if;                                                         **
  6429. --**                                                                    **
  6430. --**    if THERE_IS_NO_CURRENT_ROW then                                 **
  6431. --**            -- the CURRENT_ROW component of TABLE_NAME in the TABLE **
  6432. --**            -- status array is 'init' or 'end'                      **
  6433. --**        raise X_NO_CURRENT_ROW;                                     **
  6434. --**    end if;                                                         **
  6435. --**                                                                    **
  6436. --**    DELETE_CURRENT_ROW;                                             **
  6437. --**    UPDATE_CURRENT_ROW_STATUS;                                      **
  6438. --**                                                                    **
  6439. --**    if TABLE_IS_EMPTY then                                          **
  6440. --**        NO_MORE_ROW := TRUE;                                        **
  6441. --**    else                                                            **
  6442. --**        NO_MORE_ROW := FALSE;                                       **
  6443. --**    end if;                                                         **
  6444. --**                                                                    **
  6445. --**                                                                    **
  6446. --** INPUT--------------------------------------------------------------**
  6447. --**                                                                    **
  6448. --**  TABLE_NAME  is  the  name  of   the   table   to  be  processed.  **
  6449. --**                                                                    **
  6450. --** STATUS VARIABLES USED----------------------------------------------**
  6451. --**                                                                    **
  6452. --**    A_DATABASE_IS_OPEN                                              **
  6453. --**    TABLE.LOCK                                                      **
  6454. --**                                                                    **
  6455. --** OUTPUT-------------------------------------------------------------**
  6456. --**                                                                    **
  6457. --**  NO_MORE_ROW  is  TRUE  if  the table is left  empty,  and  FALSE  **
  6458. --**  otherwise.                                                        **
  6459. --**                                                                    **
  6460. --** STATUS VARIABLES UPDATED-------------------------------------------**
  6461. --**                                                                    **
  6462. --**                                                                    **
  6463. --** EXCEPTIONS---------------------------------------------------------**
  6464. --**                                                                    **
  6465. --**    X_TABLE_NOT_LOCKED                                              **
  6466. --**    X_NO_CURRENT_ROW                                                **
  6467. --**    X_SHARED_MODE_LOCK                                              **
  6468. --**                                                                    **
  6469. --************************************************************************
  6470.  
  6471.         IT, RTN : INTEGER;
  6472.     begin
  6473.         if not SHARE.A_DATABASE_IS_OPEN then
  6474.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6475.             "A database must be opened and a table locked to use DELETE");
  6476.             raise X_TABLE_NOT_LOCKED;
  6477.         end if;
  6478.  
  6479.         -- get the table index or raise X_TABLE_NOT_LOCKED
  6480.         IT := UTILITIES.TABLE_ID (TABLE_NAME);
  6481.  
  6482.         if TABLE (IT).TABLE_STATUS.CURRENT_LOCK = SHARED then
  6483.             -- the table should have been locked in exclusive mode
  6484.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6485.             "DELETE cannot be applied to a table locked in shared");
  6486.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6487.             "mode; it must be in exclusive mode");
  6488.             raise X_SHARED_MODE_LOCK;
  6489.         end if;
  6490.  
  6491.         if TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = 0 or
  6492.            TABLE (IT).TABLE_STATUS.CURRENT_ROW (1) = -1 then
  6493.             -- no one row is currently selected
  6494.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6495.             "A row must be selected by successfully using NEXT, PREVIOUS,");
  6496.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6497.             "FIND_NEXT or FIND_PREVIOUS before using DELETE");
  6498.             raise X_NO_CURRENT_ROW;
  6499.         end if;
  6500.  
  6501.         -- discard the current row from the table
  6502.         F77_CALLABLES.ADA_DELETT
  6503.            (TABLE (IT).TABLE_STATUS.DESCR,
  6504.             TABLE (IT).TABLE_STATUS.CURRENT_ROW, RTN);
  6505.         if RTN /= 0 then
  6506.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6507.             "internal error when deleting the old row in DELETE");
  6508.             raise X_INTERNAL_ERROR;
  6509.         end if;
  6510.  
  6511.         if F77_CALLABLES.ADA_NUMTUP (TABLE (IT).TABLE_STATUS.DESCR) = 0 then
  6512.             -- table is empty
  6513.  
  6514.             NO_MORE_ROW := TRUE;
  6515.         else
  6516.             -- table is not empty
  6517.  
  6518.             NO_MORE_ROW := FALSE;
  6519.         end if;
  6520.  
  6521.     end DELETE;
  6522.  
  6523. end LL_DAMES;
  6524. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  6525. --tabdes.txt
  6526. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  6527. package body TABLE_DESCRIPTOR is
  6528.  
  6529.     type HOOK;
  6530.     type HOOK_ACCESS is access HOOK;
  6531.     type HOOK is
  6532.         record
  6533.             FREE    : BOOLEAN;
  6534.                 -- when true, means that the hanging node is currently
  6535.                 -- unused, and can then be chosen to be returned by the
  6536.                 -- NEW_NODE function.
  6537.  
  6538.             OTHER   : HOOK_ACCESS;
  6539.                 -- points to another hook.
  6540.  
  6541.             HANGING : NODE_ACCESS;
  6542.                 -- pointer to a node which can be allocated by the
  6543.                 -- NEW_NODE function.
  6544.         end record;
  6545.  
  6546.     HEAD : HOOK_ACCESS;
  6547.         -- this variable points to the first item of a list of hooks;
  6548.         -- the hanging nodes are those who can be allocated by a call
  6549.         -- to NEW_NODE.
  6550.  
  6551.  
  6552.     type CELL;
  6553.     type CELL_ACCESS is access CELL;
  6554.     type CELL is
  6555.         record
  6556.             OTHER  : CELL_ACCESS;
  6557.             OBJECT : CONSTRAINT_ACCESS;
  6558.         end record;
  6559.     HEAD_CELL : CELL_ACCESS;
  6560.     procedure FREE_NODES (TABLE_ID : INTEGER) is
  6561.         CURSOR : HOOK_ACCESS;
  6562.     begin
  6563.         
  6564.             -- first check that no other table than the TABLE_ID one
  6565.             -- currently needs some of the already hanging nodes; if
  6566.             -- there is one (or more), no node should be freed.
  6567.         for I in 1 .. TABLE_NO loop
  6568.             if I /= TABLE_ID and then
  6569.                TABLE (I).TABLE_STATUS.TABLE_IS_LOCKED and then
  6570.                TABLE (I).TABLE_STATUS.FIND_STATUS /= DEAD then
  6571.                  -- the Ith table currently uses hanging nodes; do not
  6572.                  -- free them
  6573.                 return;
  6574.             end if;
  6575.         end loop;
  6576.  
  6577.             -- all hanging nodes can be freed
  6578.         CURSOR := HEAD;
  6579.  
  6580.         while CURSOR /= null loop
  6581.             CURSOR.all.FREE := TRUE;
  6582.             CURSOR := CURSOR.all.OTHER;
  6583.         end loop;
  6584.     end FREE_NODES;
  6585.  
  6586.  
  6587.     function NEW_NODE return NODE_ACCESS is
  6588.         CURSOR : HOOK_ACCESS;
  6589.     begin
  6590.         CURSOR := HEAD;
  6591.  
  6592.             -- look at the currently hanging nodes in order to find
  6593.             -- a free one
  6594.         while CURSOR /= null loop
  6595.             if CURSOR.all.FREE then
  6596.                 return CURSOR.all.HANGING;
  6597.             else
  6598.                 CURSOR := CURSOR.all.OTHER;
  6599.             end if;
  6600.         end loop;
  6601.  
  6602.             -- since no one of the currently hanging nodes is free, a
  6603.             -- new one is to be allocated, inserted at the beginning
  6604.             -- of the currently hanging nodes list, and its address
  6605.             -- then returned
  6606.         HEAD := new HOOK'(FALSE, HEAD, new NODE);
  6607.         return HEAD.all.HANGING;
  6608.     end NEW_NODE;
  6609.     procedure STORE_CONSTRAINT (CONSTRAINT : CONSTRAINT_ACCESS) is
  6610.         CURSOR : CELL_ACCESS;
  6611.     begin
  6612.         CURSOR := HEAD_CELL;
  6613.         while CURSOR /= null and then CURSOR.all.OBJECT /= null loop
  6614.             CURSOR := CURSOR.all.OTHER;
  6615.         end loop;
  6616.         if CURSOR = null then
  6617.             HEAD_CELL := new CELL'(HEAD_CELL, CONSTRAINT);
  6618.         else
  6619.             CURSOR.all.OBJECT := CONSTRAINT;
  6620.         end if;
  6621.     end STORE_CONSTRAINT;
  6622.  
  6623.     function NEW_CONSTRAINT return CONSTRAINT_ACCESS is
  6624.         CURSOR         : CELL_ACCESS;
  6625.         TO_BE_RETURNED : CONSTRAINT_ACCESS;
  6626.     begin
  6627.         CURSOR := HEAD_CELL;
  6628.         while CURSOR /= null and then CURSOR.all.OBJECT = null loop
  6629.             CURSOR := CURSOR.all.OTHER;
  6630.         end loop;
  6631.         if CURSOR = null then
  6632.             TO_BE_RETURNED := new STRING (1 .. 2 * RANGE_SIZE);
  6633.         else
  6634.             TO_BE_RETURNED := CURSOR.all.OBJECT;
  6635.             CURSOR.all.OBJECT := null;
  6636.         end if;
  6637.         return TO_BE_RETURNED;
  6638.     end NEW_CONSTRAINT;
  6639.  
  6640.         
  6641. end TABLE_DESCRIPTOR;
  6642. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  6643. --util.txt
  6644. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  6645. with CONSTANTS;
  6646. use CONSTANTS;
  6647.  
  6648. with LL_DAMES;
  6649. use LL_DAMES;
  6650.  
  6651. with F77_CALLABLES;
  6652.  
  6653. with UNCHECKED_CONVERSION;
  6654.  
  6655. with TEXT_IO;
  6656.  
  6657. with CONVERSION;
  6658.  
  6659. package body UTILITIES is
  6660.  
  6661.     VALUE           : INTEGER_ARRAY_TYPE (1 .. (MAX_STRING + 3) / 4) :=
  6662.                       (others => 0);
  6663.     LENR, FTYP, RTN : INTEGER;
  6664.  
  6665.  
  6666.                           ---------------
  6667.                           -- NORMALIZE --
  6668.                           ---------------
  6669.     function NORMALIZE (NAME : STRING) return STRING is
  6670.  
  6671.             -- NORMALIZE return a ten characters long character string in
  6672.             -- which the NAME in parameter has been copied after it was 
  6673.             -- 'normalized' , i.e. :
  6674.             --      cut if too long,
  6675.             --      completed to blank if too short,
  6676.             --      skip beginning blanks,
  6677.             --      uppercased
  6678.  
  6679.         TO_BE_RETURNED : STRING (1 .. NAME_LENGTH);
  6680.     begin
  6681.         if NAME'LENGTH > NAME_LENGTH then
  6682.                 -- NAME is too long and must be cut
  6683.  
  6684.             TO_BE_RETURNED := NAME (NAME'FIRST .. NAME'FIRST + NAME_LENGTH - 1);
  6685.         else
  6686.                 -- NAME is too short and must be completed with blanks
  6687.             TO_BE_RETURNED := NAME & (NAME'LENGTH + 1 .. NAME_LENGTH => ' ');
  6688.         end if;
  6689.  
  6690.         if TO_BE_RETURNED /= (1 .. NAME_LENGTH => ' ') then
  6691.             while TO_BE_RETURNED (1) = ' ' loop
  6692.                     -- discard the first character if blank
  6693.                 TO_BE_RETURNED := TO_BE_RETURNED (2 .. NAME_LENGTH) & ' ';
  6694.             end loop;
  6695.         end if;
  6696.  
  6697.         for I in 1 .. NAME_LENGTH loop
  6698.                 -- loop for each character
  6699.  
  6700.             if TO_BE_RETURNED (I) >= 'a' then
  6701.                     -- the character is a lower-case letter which will be
  6702.                     -- converted to its upper-case equivalent
  6703.  
  6704.                 TO_BE_RETURNED (I) :=
  6705.                   CHARACTER'VAL (CHARACTER'POS (TO_BE_RETURNED (I)) - 32);
  6706.             end if;
  6707.         end loop;
  6708.         return TO_BE_RETURNED;
  6709.     end NORMALIZE;
  6710.  
  6711.  
  6712.                           --------------
  6713.                           -- BIT_SIZE --
  6714.                           --------------
  6715.     function BIT_SIZE (TABLE_ID  : INTEGER;
  6716.                        COLUMN_ID : INTEGER) return INTEGER is
  6717.  
  6718.         -- return the size (in bits) of the Ada type associated to a
  6719.         -- scalar column.
  6720.  
  6721.     begin
  6722.         case TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_TYPES (COLUMN_ID) is
  6723.                 -- INTEGER type
  6724.             when 1 =>  return INTEGER'SIZE;
  6725.  
  6726.                 -- FLOAT type
  6727.             when 2 =>  return FLOAT'SIZE;
  6728.  
  6729.                 -- ENUMERATION or STRING type
  6730.             when 5 => 
  6731.                 if TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES (COLUMN_ID)
  6732.                   = null then
  6733.                         -- STRING type
  6734.                     declare
  6735.                         S : STRING
  6736.                               (1 .. TABLE (TABLE_ID).TABLE_DEFINITION
  6737.                                      .COLUMN_LENGTH (COLUMN_ID));
  6738.                     begin
  6739.                         return S'SIZE;
  6740.                     end;
  6741.                 else
  6742.                         -- ENUMERATION type
  6743.                     return BOOLEAN'SIZE;
  6744.                 end if;
  6745.  
  6746.             when others =>
  6747.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6748.                 "internal error when evaluating a type definition");
  6749.                 raise X_INTERNAL_ERROR;
  6750.         end case;
  6751.     end BIT_SIZE;
  6752.  
  6753.  
  6754.                        ---------------------
  6755.                        -- RECORD_BIT_SIZE --
  6756.                        ---------------------
  6757.     function RECORD_BIT_SIZE (TABLE_ID  : INTEGER;
  6758.                               COLUMN_ID : INTEGER;
  6759.                               IS_RECORD : BOOLEAN) return INTEGER is
  6760.  
  6761.             -- return the size of a column of a table; this column can either
  6762.             -- be a scalar or a record column, depending on IS_RECORD
  6763.  
  6764.         IC, ACTUAL_SIZE : INTEGER;
  6765.         RECORD_NAME     : STRING (1 .. NAME_LENGTH);     begin
  6766.         if IS_RECORD then
  6767.                 -- the column is a record column
  6768.  
  6769.             ACTUAL_SIZE := 0;
  6770.             IC := COLUMN_ID;
  6771.             RECORD_NAME := TABLE (TABLE_ID).TABLE_DEFINITION.IN_RECORD (IC);
  6772.                 -- the name of the record column is stored in RECORD_NAME
  6773.  
  6774.             while TABLE (TABLE_ID).TABLE_DEFINITION.IN_RECORD (IC) =
  6775.                   RECORD_NAME loop
  6776.                     -- loop while the ICth scalar column is a component of 
  6777.                     -- the RECORD_NAME record column
  6778.  
  6779.                 ACTUAL_SIZE := ACTUAL_SIZE + BIT_SIZE (TABLE_ID, IC);
  6780.                 exit when IC = TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NUMBER;
  6781.                 IC := IC + 1;
  6782.             end loop;
  6783.  
  6784.             return ACTUAL_SIZE;
  6785.         else
  6786.                 -- the column is a scalar column
  6787.             return BIT_SIZE (TABLE_ID, COLUMN_ID);
  6788.         end if;
  6789.     end RECORD_BIT_SIZE;
  6790.  
  6791.  
  6792.                          ----------------
  6793.                          -- TABLE_SIZE --
  6794.                          ----------------
  6795.     function TABLE_SIZE (TABLE_ID : INTEGER) return INTEGER is
  6796.  
  6797.             -- TABLE_SIZE returns the size (in bits) of the record type
  6798.             -- which corresponds to a row of this table
  6799.  
  6800.         ACTUAL_SIZE : INTEGER;
  6801.     begin
  6802.         ACTUAL_SIZE := 0;
  6803.  
  6804.         for I in 1 .. TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NUMBER loop
  6805.             ACTUAL_SIZE := ACTUAL_SIZE + BIT_SIZE (TABLE_ID, I);
  6806.         end loop;
  6807.  
  6808.         return ACTUAL_SIZE;
  6809.     end TABLE_SIZE;
  6810.  
  6811.  
  6812.                           --------------
  6813.                           -- TABLE_ID --
  6814.                           --------------
  6815.     function TABLE_ID (TABLE_NAME : STRING) return INTEGER is
  6816.  
  6817.             -- TABLE_ID returns the index in TABLE_DESCRIPTOR of the locked
  6818.             -- table  the  name  of  which  is  TABLE_NAME ,  or  raise
  6819.             -- X_TABLE_NOT_LOCKED if this name is unknown
  6820.  
  6821.         TABLE_NAME2 : STRING (1 .. NAME_LENGTH);
  6822.         IT          : INTEGER;     begin
  6823.             -- first normalize the name to compare it to those already known
  6824.         TABLE_NAME2 := NORMALIZE (TABLE_NAME);
  6825.         IT := 1;
  6826.  
  6827.         loop
  6828.             if TABLE_NAME2 = TABLE (IT).NAME then
  6829.                     -- the searched name is found
  6830.                 if TABLE (IT).TABLE_STATUS.TABLE_IS_LOCKED = TRUE then
  6831.                         -- the table is locked
  6832.                     exit;
  6833.                 else
  6834.                         -- the table is unlocked
  6835.                     UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6836.                     "unknown table among locked ones");
  6837.                     raise X_TABLE_NOT_LOCKED;
  6838.                 end if;
  6839.             end if;
  6840.  
  6841.             IT := IT + 1;
  6842.  
  6843.             if IT = TABLE_NO + 1 then
  6844.                     -- the last possible value for IT is reached but the
  6845.                     -- searched name is not found : it means the table is
  6846.                     -- unlocked
  6847.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6848.                 "unknown table among locked ones");
  6849.                 raise X_TABLE_NOT_LOCKED;
  6850.             end if;
  6851.         end loop;
  6852.  
  6853.         return IT;
  6854.     end TABLE_ID;
  6855.  
  6856.  
  6857.                       ----------------------
  6858.                       -- SCALAR_COLUMN_ID --
  6859.                       ----------------------
  6860.     function SCALAR_COLUMN_ID (TABLE_ID    : INTEGER;
  6861.                                COLUMN_NAME : STRING) return INTEGER is
  6862.  
  6863.             -- return the index of a scalar column or raise X_INVALID_COLUMN
  6864.             -- if this one can not be found
  6865.  
  6866.         COLUMN_NAME2 : STRING (1 .. NAME_LENGTH);
  6867.         IC           : INTEGER;
  6868.     begin
  6869.             -- first normalize the name of the column to enable comparisons
  6870.         COLUMN_NAME2 := NORMALIZE (COLUMN_NAME);
  6871.         IC := 1;
  6872.  
  6873.         loop
  6874.             exit when COLUMN_NAME2 =
  6875.                       TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NAMES (IC);
  6876.                 -- exit from the loop when the searched name is found
  6877.  
  6878.             IC := IC + 1;
  6879.             if IC = TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NUMBER + 1 then
  6880.                     -- the searched name has been compared to all the names
  6881.                     -- of the table without equality
  6882.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6883.                 "unknown column name among all scalar ones");
  6884.                 raise X_INVALID_COLUMN;
  6885.             end if;
  6886.         end loop;
  6887.  
  6888.         return IC;
  6889.     end SCALAR_COLUMN_ID;
  6890.  
  6891.  
  6892.                            ------------
  6893.                            -- COLUMN --
  6894.                            ------------
  6895.     procedure COLUMN (TABLE_ID    : INTEGER;
  6896.                       COLUMN_NAME : STRING;
  6897.                       COLUMN_ID   : out INTEGER;
  6898.                       IS_RECORD   : out BOOLEAN) is
  6899.  
  6900.             -- COLUMN returns in COLUMN_ID the index of the COLTUMN_NAME column
  6901.             -- or raise X_INVALID_COLUMN if this one is unknown; IS_RECORD is
  6902.             -- returned 'false' if the column is a scalar one, and 'true' if it
  6903.             -- is a record one and not a scalar one.
  6904.  
  6905.         COLUMN_NAME2 : STRING (1 .. NAME_LENGTH);
  6906.         IC           : INTEGER;
  6907.     begin
  6908.             -- first normalize the name to compare it to other names
  6909.         COLUMN_NAME2 := NORMALIZE (COLUMN_NAME);
  6910.         IC := 1;
  6911.         IS_RECORD := FALSE;
  6912.  
  6913.         OUTER_LOOP:
  6914.         loop
  6915.             exit when COLUMN_NAME2 =
  6916.                       TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NAMES (IC);
  6917.                 -- exit from the loop when the searched column is found as
  6918.                 -- a scalar one
  6919.  
  6920.             IC := IC + 1;
  6921.  
  6922.             if IC = TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NUMBER + 1 then
  6923.                     -- none of the scalar columns is the one searched
  6924.  
  6925.                 IS_RECORD := TRUE;
  6926.                 IC := 1;
  6927.  
  6928.                 loop
  6929.                     exit OUTER_LOOP when COLUMN_NAME2 =
  6930.                                          TABLE (TABLE_ID).TABLE_DEFINITION
  6931.                                           .IN_RECORD (IC);
  6932.                         -- exit from loop when the searched column is found as
  6933.                         -- a record one
  6934.  
  6935.                     IC := IC + 1;
  6936.                     if IC =
  6937.                        TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_NUMBER + 1 then
  6938.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6939.                         "unknown column among all scalar and record ones");
  6940.                         raise X_INVALID_COLUMN;
  6941.                     end if;
  6942.                 end loop;
  6943.             end if;
  6944.         end loop OUTER_LOOP;
  6945.  
  6946.         COLUMN_ID := IC;
  6947.     end COLUMN;
  6948.  
  6949.  
  6950.  
  6951.                  ---------------------------------
  6952.                  -- SELECTION_CRITERION_IS_TRUE --
  6953.                  ---------------------------------
  6954.     function SELECTION_CRITERION_IS_TRUE (TABLE_ID : INTEGER;
  6955.                                           CURSOR   : NODE_ACCESS)
  6956.                                            return BOOLEAN is
  6957.  
  6958.         -- SELECTION_CRITERION_IS_TRUE returns TRUE if the selection criterion
  6959.         -- defined by CURSOR (CURSOR is the root of a tree which is supposed to
  6960.         -- be the selection criterion) is true for the current row of the table
  6961.         -- TABLE_ID, and FALSE if the criterion is false.
  6962.         -- Since the selection criterion is a tree, each subtree can be used by
  6963.         -- chosing for CURSOR a node which is not the root.
  6964.  
  6965.     begin
  6966.         if CURSOR.all.FIRST_CHILD = null then
  6967.                 -- CURSOR is a leave of the binary tree; a test must be done
  6968.  
  6969.                 -- first get the value of the current row to be tested
  6970.             VALUE := (1 .. VALUE'LENGTH => 0);
  6971.             F77_CALLABLES.ADA_GETA
  6972.                (TABLE (TABLE_ID).TABLE_STATUS.DESCR,
  6973.                 TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_INDEX
  6974.                    (CURSOR.all.COLUMN_ID), VALUE, LENR, FTYP, RTN);
  6975.             if RTN /= 0 then
  6976.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6977.                 "internal error when reading a value to be used");
  6978.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  6979.                 "in a selection criterion");
  6980.                 raise X_INTERNAL_ERROR;
  6981.             end if;
  6982.  
  6983.             if TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES
  6984.                   (CURSOR.all.COLUMN_ID) /= null then
  6985.                         -- the value is of an enumeration type and the string
  6986.                         -- we got in value must be converted to its position
  6987.                         -- while the order on enumeration item is by position
  6988.                         -- and not by lexicographic order on images
  6989.  
  6990.                 VALUE (1) := CONVERSION.ADA_ENUM
  6991.                                 (VALUE,
  6992.                                  TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES
  6993.                                     (CURSOR.all.COLUMN_ID));
  6994.             end if;
  6995.             case CURSOR.all.KEY_MATCH is
  6996.  
  6997.  
  6998.  
  6999.                 when EQUAL            =>  return VALUE (1 .. CURSOR.all
  7000.                                                               .MEANINGFUL) =
  7001.                                                  CURSOR.all.COLUMN_VALUE
  7002.                                                     (1 .. CURSOR.all
  7003.                                                            .MEANINGFUL);
  7004.  
  7005.  
  7006.  
  7007.                 when NOT_EQUAL        =>  return VALUE (1 .. CURSOR.all
  7008.                                                               .MEANINGFUL) /=
  7009.                                                  CURSOR.all.COLUMN_VALUE
  7010.                                                     (1 .. CURSOR.all
  7011.                                                            .MEANINGFUL);
  7012.  
  7013.  
  7014.  
  7015.                 when LESS             =>  return VALUE (1 .. CURSOR.all
  7016.                                                               .MEANINGFUL) <
  7017.                                                  CURSOR.all.COLUMN_VALUE
  7018.                                                     (1 .. CURSOR.all
  7019.                                                            .MEANINGFUL);
  7020.  
  7021.  
  7022.  
  7023.                 when LESS_OR_EQUAL    =>  return VALUE (1 .. CURSOR.all
  7024.                                                               .MEANINGFUL) <=
  7025.                                                  CURSOR.all.COLUMN_VALUE
  7026.                                                     (1 .. CURSOR.all
  7027.                                                            .MEANINGFUL);
  7028.  
  7029.  
  7030.  
  7031.                 when GREATER          =>  return VALUE (1 .. CURSOR.all
  7032.                                                               .MEANINGFUL) >
  7033.                                                  CURSOR.all.COLUMN_VALUE
  7034.                                                     (1 .. CURSOR.all
  7035.                                                            .MEANINGFUL);
  7036.  
  7037.  
  7038.  
  7039.                 when GREATER_OR_EQUAL =>  return VALUE (1 .. CURSOR.all
  7040.                                                               .MEANINGFUL) >=
  7041.                                                  CURSOR.all.COLUMN_VALUE
  7042.                                                     (1 .. CURSOR.all
  7043.                                                            .MEANINGFUL);
  7044.             end case;
  7045.  
  7046.         elsif CURSOR.all.TREE_OPERATOR = AND_OPERATOR then
  7047.                 -- CURSOR is not a leave of the binary tree;
  7048.                 -- SELECTION_CRITERION_IS_TRUE must be called again for
  7049.                 -- the two subtree of CURSOR and a AND will be performed
  7050.                 -- on the two results
  7051.  
  7052.             return SELECTION_CRITERION_IS_TRUE
  7053.                       (TABLE_ID, CURSOR.all.FIRST_CHILD) and
  7054.                    SELECTION_CRITERION_IS_TRUE
  7055.                       (TABLE_ID, CURSOR.all.SECOND_CHILD);         else
  7056.                 -- CURSOR is not a leave of the binary tree;
  7057.                 -- SELECTION_CRITERION_IS_TRUE must be called again for
  7058.                 -- the two subtree of CURSOR and a OR will be performed
  7059.                 -- on the two results
  7060.  
  7061.             return SELECTION_CRITERION_IS_TRUE
  7062.                       (TABLE_ID, CURSOR.all.FIRST_CHILD) or
  7063.                    SELECTION_CRITERION_IS_TRUE
  7064.                       (TABLE_ID, CURSOR.all.SECOND_CHILD);
  7065.         end if;
  7066.     end SELECTION_CRITERION_IS_TRUE;
  7067.  
  7068.  
  7069.     function INTEGER_TO_FLOAT is new UNCHECKED_CONVERSION (INTEGER, FLOAT);
  7070.  
  7071.     package PURE_FLOAT_IO is new TEXT_IO.FLOAT_IO (FLOAT);
  7072.  
  7073.  
  7074.                          -----------------
  7075.                          -- CHECK_VALUE --
  7076.                          -----------------
  7077.     procedure CHECK_VALUE (CHECKED, TABLE_ID, COLUMN_ID : INTEGER) is
  7078.  
  7079.                 -- This procedure checks that the value contained in
  7080.                 -- CHECKED is in the range associated to the column
  7081.                 -- defined by TABLE_ID and COLUMN_ID; this column is
  7082.                 -- supposed to have actually a range constraint, otherwise
  7083.                 -- CHECK_VALUE will fail.
  7084.                 -- If the check is successful, nothing is done, but if
  7085.                 -- the check fails, X_INVALID_VALUE is raised.
  7086.  
  7087.         LAST : POSITIVE;
  7088.         MIN_FLOAT, MAX_FLOAT, FLOAT_OBJECT : FLOAT;
  7089.         CONSTRAINT : STRING renames
  7090.           TABLE (TABLE_ID).TABLE_DEFINITION.CONSTRAINTS (COLUMN_ID).all;
  7091.     begin
  7092.         case TABLE (TABLE_ID).TABLE_DEFINITION.COLUMN_TYPES (COLUMN_ID) is
  7093.  
  7094.             when 1 =>
  7095.                         -- INTEGER type
  7096.                 if CHECKED < INTEGER'VALUE (CONSTRAINT (1 .. RANGE_SIZE))
  7097.                 or CHECKED > INTEGER'VALUE (CONSTRAINT
  7098.                   (RANGE_SIZE + 1 .. 2 * RANGE_SIZE)) then
  7099.                     UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7100.                     "an integer range constraint has been violated");
  7101.                     raise X_INVALID_VALUE;
  7102.                 end if;
  7103.  
  7104.             when 2 =>
  7105.                         -- FLOAT type
  7106.                 FLOAT_OBJECT := INTEGER_TO_FLOAT (CHECKED);
  7107.                 PURE_FLOAT_IO.GET (CONSTRAINT (1 .. RANGE_SIZE),
  7108.                   MIN_FLOAT, LAST);
  7109.                 PURE_FLOAT_IO.GET (CONSTRAINT
  7110.                   (RANGE_SIZE + 1 .. 2 * RANGE_SIZE), MAX_FLOAT, LAST);
  7111.                 if FLOAT_OBJECT < MIN_FLOAT or FLOAT_OBJECT > MAX_FLOAT then
  7112.                     UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7113.                     "a float range constraint has been violated");
  7114.                     raise X_INVALID_VALUE;
  7115.                 end if;
  7116.                      when 5 =>
  7117.                         -- ENUMERATION type or STRING type
  7118.                 if TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES (COLUMN_ID)
  7119.                   /= null then
  7120.                         -- enumeration type
  7121.                     if CHECKED < CONVERSION.ADA_ENUM
  7122.                         (CONVERSION.F77_STRING
  7123.                           (CONSTRAINT (1 .. RANGE_SIZE)),
  7124.                 TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES (COLUMN_ID))
  7125.                       or CHECKED > CONVERSION.ADA_ENUM
  7126.                         (CONVERSION.F77_STRING
  7127.                           (CONSTRAINT (RANGE_SIZE + 1 .. 2 * RANGE_SIZE)),
  7128.                 TABLE (TABLE_ID).TABLE_DEFINITION.ENUM_TYPES (COLUMN_ID))
  7129.                       then
  7130.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7131.                         "an enumeration range constraint has been violated");
  7132.                         raise X_INVALID_VALUE;
  7133.                     end if;
  7134.                 end if;
  7135.             when others =>
  7136.                 null;
  7137.         end case;
  7138.     end CHECK_VALUE;
  7139.  
  7140.  
  7141.     procedure OUTPUT_MESSAGE (MESSAGE : STRING) is
  7142.     begin
  7143.             -- The message can be outputed either by using the MESSAGE
  7144.             -- command of the User Language through the DAMES.EXECUTE
  7145.             -- procedure, or by using a dedicated Fortran subroutine.
  7146.         F77_CALLABLES.ADA_MSGTTY (MESSAGE, MESSAGE'LENGTH);
  7147.     end OUTPUT_MESSAGE;
  7148.  
  7149. end UTILITIES;
  7150. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  7151. --adatab.txt
  7152. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  7153. with CONSTANTS;
  7154. use CONSTANTS;
  7155.  
  7156. with F77_CALLABLES;
  7157. use F77_CALLABLES;
  7158.  
  7159. with LL_DAMES;
  7160.  
  7161. with UTILITIES;
  7162.  
  7163. with CONVERSION;
  7164.  
  7165. package body ADA_TABLES is
  7166.  
  7167.     TABLES_EXIST                                 : BOOLEAN;
  7168.         -- TRUE when the three reserved tables exist in the currently
  7169.         -- open database, and FALSE otherwise (when they do not exist,
  7170.         -- they are considered as existing, but empty)
  7171.  
  7172.     ACTUAL_USER_TABLE_NAME                       : STRING (1 .. NAME_LENGTH);
  7173.         -- name of a table to be used as key for the TABLE_NAME column
  7174.         -- of the reserved tables
  7175.  
  7176.     RANGE_TIDD, RECORD_TIDD, ENUM_TIDD, TIDD     : TIDD_TYPE;
  7177.         -- used to keep the current rows of the reserved tables
  7178.         -- during updating or scanning
  7179.  
  7180.     DESCR, RANGE_DESCR, RECORD_DESCR, ENUM_DESCR : INTEGER;
  7181.         -- used to keep the identifiers of the tables usd by the
  7182.         -- fortran access procedures
  7183.  
  7184.  
  7185.  
  7186.                ------------------------------------
  7187.                -- LOCK_ADA_TABLES_IN_SHARED_MODE --
  7188.                ------------------------------------
  7189.     procedure LOCK_ADA_TABLES_IN_SHARED_MODE is
  7190.         RTN : INTEGER;
  7191.     begin
  7192.         -- set the three shared locks
  7193.         ADA_DLOCK ("ADARANGE    ADARECORD   ADAENUM     ",
  7194.                 (1 .. 3 => 0), 3, RTN);
  7195.         if RTN /= 0 then
  7196.             TABLES_EXIST := FALSE;
  7197.         else
  7198.             TABLES_EXIST := TRUE;
  7199.         end if;
  7200.     end LOCK_ADA_TABLES_IN_SHARED_MODE;
  7201.  
  7202.  
  7203.               ---------------------------------------
  7204.               -- LOCK_ADA_TABLES_IN_EXCLUSIVE_MODE --
  7205.               ---------------------------------------
  7206.     procedure LOCK_ADA_TABLES_IN_EXCLUSIVE_MODE (USER_TABLE_NAME : STRING) is
  7207.         DOMAIN_NAME : constant STRING (1 .. 12) :=
  7208.                       (1 .. 4 => ASCII.NUL, 5 .. 12 => ' ');
  7209.         RCKEY, RTN  : INTEGER;
  7210.  
  7211.     begin
  7212.                 -- set the three exclusive locks
  7213.         ADA_DLOCK ("ADARANGE    ADARECORD   ADAENUM     ",
  7214.                 (1 .. 3 => 1), 3, RTN);
  7215.         if RTN /= 0 then
  7216.             ADA_IRELC ("ADARANGE  ", RCKEY, 1);
  7217.                 -- initialize the creation of the ADARANGE table
  7218.  
  7219.             ADA_ADDATR (RCKEY, "TABLENAME ", 5, NAME_LENGTH, DOMAIN_NAME, RTN);
  7220.             if RTN /= 0 then
  7221.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7222.                 "internal error when creating the ADARANGE internal table");
  7223.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7224.             end if;
  7225.             ADA_ADDATR (RCKEY, "COLNAME   ", 5, NAME_LENGTH, DOMAIN_NAME, RTN);
  7226.             if RTN /= 0 then
  7227.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7228.                 "internal error when creating the ADARANGE internal table");
  7229.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7230.             end if;
  7231.             ADA_ADDATR (RCKEY, "MINVALUE  ", 5, RANGE_SIZE, DOMAIN_NAME, RTN);
  7232.             if RTN /= 0 then
  7233.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7234.                 "internal error when creating the ADARANGE internal table");
  7235.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7236.             end if;
  7237.             ADA_ADDATR (RCKEY, "MAXVALUE  ", 5, RANGE_SIZE, DOMAIN_NAME, RTN);
  7238.             if RTN /= 0 then
  7239.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7240.                 "internal error when creating the ADARANGE internal table");
  7241.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7242.             end if;
  7243.                 -- define its four attributes
  7244.  
  7245.             ADA_TRELC (RCKEY, 1, 0, 0, RTN);
  7246.                 -- terminate the table creation
  7247.             if RTN /= 0 then
  7248.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7249.                 "internal error when creating the ADARANGE internal table");
  7250.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7251.             end if;
  7252.  
  7253.  
  7254.             ADA_IRELC ("ADARECORD ", RCKEY, 1);
  7255.                 -- initialize the creation of the ADARECORD table
  7256.             ADA_ADDATR (RCKEY, "TABLENAME ", 5, NAME_LENGTH, DOMAIN_NAME, RTN);
  7257.             if RTN /= 0 then
  7258.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7259.                 "internal error when creating the ADARECORD internal table");
  7260.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7261.             end if;
  7262.             ADA_ADDATR (RCKEY, "RECORDNAME", 5, NAME_LENGTH, DOMAIN_NAME, RTN);
  7263.             if RTN /= 0 then
  7264.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7265.                 "internal error when creating the ADARECORD internal table");
  7266.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7267.             end if;
  7268.             ADA_ADDATR (RCKEY, "COMPONENT ", 5, NAME_LENGTH, DOMAIN_NAME, RTN);
  7269.             if RTN /= 0 then
  7270.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7271.                 "internal error when creating the ADARECORD internal table");
  7272.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7273.             end if;
  7274.                 -- define its three attributes
  7275.  
  7276.             ADA_TRELC (RCKEY, 1, 0, 0, RTN);
  7277.                 -- terminate the table creation
  7278.             if RTN /= 0 then
  7279.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7280.                 "internal error when creating the ADARECORD internal table");
  7281.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7282.             end if;
  7283.  
  7284.  
  7285.             ADA_IRELC ("ADAENUM   ", RCKEY, 1);
  7286.                 -- initialize the creation of the ADAENUM table
  7287.  
  7288.             ADA_ADDATR (RCKEY, "TABLENAME ", 5, NAME_LENGTH, DOMAIN_NAME, RTN);
  7289.             if RTN /= 0 then
  7290.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7291.                 "internal error when creating the ADAENUM internal table");
  7292.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7293.             end if;
  7294.             ADA_ADDATR (RCKEY, "COLNAME   ", 5, NAME_LENGTH, DOMAIN_NAME, RTN);
  7295.             if RTN /= 0 then
  7296.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7297.                 "internal error when creating the ADAENUM internal table");
  7298.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7299.             end if;
  7300.             ADA_ADDATR (RCKEY, "VALUE     ", 1, 4, DOMAIN_NAME, RTN);
  7301.             if RTN /= 0 then
  7302.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7303.                 "internal error when creating the ADAENUM internal table");
  7304.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7305.             end if;
  7306.             ADA_ADDATR (RCKEY, "IMAGE     ", 5, IMAGE_SZ, DOMAIN_NAME, RTN);
  7307.             if RTN /= 0 then
  7308.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7309.                 "internal error when creating the ADAENUM internal table");
  7310.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7311.             end if;
  7312.                 -- define its four attributes
  7313.             ADA_TRELC (RCKEY, 1, 0, 0, RTN);
  7314.                 -- terminate the table creation
  7315.             if RTN /= 0 then
  7316.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7317.                 "internal error when creating the ADAENUM internal table");
  7318.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7319.             end if;
  7320.  
  7321.                 -- set the three exclusive locks
  7322.             ADA_DLOCK ("ADARANGE    ADARECORD   ADAENUM     ",
  7323.                 (1 .. 3 => 1), 3, RTN);
  7324.             if RTN /= 0 then
  7325.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7326.                 "internal error when locking the three reserved tables");
  7327.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7328.             end if;
  7329.         end if;
  7330.  
  7331.         ADA_OPENR ("ADARANGE  ", RANGE_DESCR, RTN);
  7332.         if RTN /= 0 then
  7333.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7334.             "internal error when opening the ADARANGE internal table");
  7335.             raise LL_DAMES.X_INTERNAL_ERROR;
  7336.         end if;
  7337.         ADA_OPENR ("ADARECORD ", RECORD_DESCR, RTN);
  7338.         if RTN /= 0 then
  7339.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7340.             "internal error when opening the ADARECORD internal table");
  7341.             raise LL_DAMES.X_INTERNAL_ERROR;
  7342.         end if;
  7343.         ADA_OPENR ("ADAENUM   ", ENUM_DESCR, RTN);
  7344.         if RTN /= 0 then
  7345.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7346.             "internal error when opening the ADAENUM internal table");
  7347.             raise LL_DAMES.X_INTERNAL_ERROR;
  7348.         end if;
  7349.                 -- open the three reserved tables
  7350.  
  7351.         RANGE_TIDD (1) := -1;
  7352.         RECORD_TIDD (1) := -1;
  7353.         ENUM_TIDD (1) := -1;
  7354.                 -- initialize the current row to the beginning of the
  7355.                 -- tables
  7356.  
  7357.         ACTUAL_USER_TABLE_NAME := USER_TABLE_NAME;
  7358.     end LOCK_ADA_TABLES_IN_EXCLUSIVE_MODE;
  7359.  
  7360.  
  7361.                        --------------------
  7362.                        -- OPEN_ADA_TABLE --
  7363.                        --------------------
  7364.     procedure OPEN_ADA_TABLE (ADA_TABLE_NAME : STRING) is
  7365.         RTN : INTEGER;
  7366.     begin
  7367.         if TABLES_EXIST then
  7368.             ADA_OPENR (ADA_TABLE_NAME, DESCR, RTN);
  7369.             if RTN /= 0 then
  7370.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7371.                 "internal error when opening the " & ADA_TABLE_NAME
  7372.                 & " internal table");
  7373.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7374.             end if;
  7375.         end if;
  7376.     end OPEN_ADA_TABLE;
  7377.  
  7378.  
  7379.  
  7380.                        ---------------------
  7381.                        -- RESET_ADA_TABLE --
  7382.                        ---------------------
  7383.     procedure RESET_ADA_TABLE (USER_TABLE_NAME : STRING) is
  7384.         RTN : INTEGER;
  7385.     begin
  7386.         if TABLES_EXIST then
  7387.             ADA_SETGET (DESCR, 3, TIDD, TIDD, RTN);
  7388.             if RTN /= 0 then
  7389.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7390.                 "internal error when initializing the current row ");
  7391.                 UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7392.                 "of a reserved table");
  7393.                 raise LL_DAMES.X_INTERNAL_ERROR;
  7394.             end if;
  7395.             TIDD (1) := -1;
  7396.                 -- reset the current row to the first one of the table
  7397.  
  7398.             ACTUAL_USER_TABLE_NAME := USER_TABLE_NAME;
  7399.         end if;
  7400.     end RESET_ADA_TABLE;
  7401.  
  7402.  
  7403.  
  7404.  
  7405.                           ---------------
  7406.                           -- GET_RANGE --
  7407.                           ---------------
  7408.     procedure GET_RANGE (COLNAME            : out STRING;
  7409.                          MINVALUE, MAXVALUE : out STRING;
  7410.                          EOF                : out BOOLEAN) is
  7411.         FTYP, LENR, ATIDX, RTN : INTEGER;
  7412.         VALUE                  : INTEGER_ARRAY_TYPE (1 .. 3);
  7413.         VALUE2                 : INTEGER_ARRAY_TYPE
  7414.                                         (1 .. (RANGE_SIZE + 3) / 4);
  7415.     begin
  7416.         if TABLES_EXIST then
  7417.             ADA_GETT (DESCR, TIDD, RTN);
  7418.                 -- fetch next row
  7419.  
  7420.             ADA_SRCHA (DESCR, "TABLENAME ", ATIDX);
  7421.                 -- read the index neccessary to access the table
  7422.             while RTN = 0 loop
  7423.                 -- last row not already found
  7424.  
  7425.                 ADA_GETA (DESCR, ATIDX, VALUE, LENR, FTYP, RTN);
  7426.                         -- get into VALUE the attribute defined by ATIDX
  7427.                 if RTN /= 0 then
  7428.                     UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7429.                     "internal error when reading TABLENAME from ADARANGE");
  7430.                     raise LL_DAMES.X_INTERNAL_ERROR;
  7431.                 end if;
  7432.  
  7433.                 if CONVERSION.ADA_STRING (VALUE, FALSE) (1 .. NAME_LENGTH)
  7434.                                     = ACTUAL_USER_TABLE_NAME then
  7435.                         -- keep this tuple
  7436.  
  7437.                         -- get the name of the concerned column
  7438.                     ADA_SRCHA (DESCR, "COLNAME   ", ATIDX);
  7439.                     ADA_GETA (DESCR, ATIDX, VALUE, LENR, FTYP, RTN);
  7440.                     if RTN /= 0 then
  7441.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7442.                         "internal error when reading COLNAME from ADARANGE");
  7443.                         raise LL_DAMES.X_INTERNAL_ERROR;
  7444.                     end if;
  7445.                     COLNAME := CONVERSION.ADA_STRING (VALUE, FALSE)
  7446.                                                 (1 .. NAME_LENGTH);
  7447.  
  7448.                         -- get the range minimum value
  7449.                     ADA_SRCHA (DESCR, "MINVALUE  ", ATIDX);
  7450.                     ADA_GETA (DESCR, ATIDX, VALUE2, LENR, FTYP, RTN);
  7451.                     if RTN /= 0 then
  7452.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7453.                         "internal error when reading MINVALUE from ADARANGE");
  7454.                         raise LL_DAMES.X_INTERNAL_ERROR;
  7455.                     end if;
  7456.                     MINVALUE:= CONVERSION.ADA_STRING (VALUE2, FALSE)
  7457.                                                 (1 .. RANGE_SIZE);
  7458.  
  7459.                         -- get the range maximum value
  7460.                     ADA_SRCHA (DESCR, "MAXVALUE  ", ATIDX);
  7461.                     ADA_GETA (DESCR, ATIDX, VALUE2, LENR, FTYP, RTN);
  7462.                     if RTN /= 0 then
  7463.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7464.                         "internal error when reading MAXVALUE from ADARANGE");
  7465.                         raise LL_DAMES.X_INTERNAL_ERROR;
  7466.                     end if;
  7467.                     MAXVALUE:= CONVERSION.ADA_STRING (VALUE2, FALSE)
  7468.                                                 (1 .. RANGE_SIZE);
  7469.  
  7470.                     EOF := FALSE;
  7471.                     return;
  7472.                 end if;
  7473.  
  7474.                 ADA_GETT (DESCR, TIDD, RTN);
  7475.                         -- look for another row
  7476.  
  7477.             end loop;
  7478.         end if;
  7479.         EOF := TRUE;
  7480.     end GET_RANGE;
  7481.  
  7482.                          ----------------
  7483.                          -- GET_RECORD --
  7484.                          ----------------
  7485.     procedure GET_RECORD (RECORD_NAME, COMPONENT : out STRING;
  7486.                           EOF                    : out BOOLEAN) is
  7487.         FTYP, LENR, ATIDX, RTN : INTEGER;
  7488.         VALUE                  : INTEGER_ARRAY_TYPE (1 .. 3);
  7489.     begin
  7490.         if TABLES_EXIST then
  7491.             ADA_GETT (DESCR, TIDD, RTN);
  7492.             ADA_SRCHA (DESCR, "TABLENAME ", ATIDX);
  7493.  
  7494.             while RTN = 0 loop
  7495.                 ADA_GETA (DESCR, ATIDX, VALUE, LENR, FTYP, RTN);
  7496.                 if RTN /= 0 then
  7497.                     UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7498.                     "internal error when reading TABLENAME from ADARECORD");
  7499.                     raise LL_DAMES.X_INTERNAL_ERROR;
  7500.                 end if;
  7501.                 if CONVERSION.ADA_STRING (VALUE, FALSE) (1 .. NAME_LENGTH)
  7502.                                     = ACTUAL_USER_TABLE_NAME then
  7503.                         -- get the name of the encapsulating record
  7504.                     ADA_SRCHA (DESCR, "RECORDNAME", ATIDX);
  7505.                     ADA_GETA (DESCR, ATIDX, VALUE, LENR, FTYP, RTN);
  7506.                     if RTN /= 0 then
  7507.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7508.                     "internal error when reading RECORDNAME from ADARECORD");
  7509.                         raise LL_DAMES.X_INTERNAL_ERROR;
  7510.                     end if;
  7511.                     RECORD_NAME:= CONVERSION.ADA_STRING (VALUE, FALSE)
  7512.                                                 (1 .. NAME_LENGTH);
  7513.  
  7514.                         -- get the name of the concerned component
  7515.                     ADA_SRCHA (DESCR, "COMPONENT ", ATIDX);
  7516.                     ADA_GETA (DESCR, ATIDX, VALUE, LENR, FTYP, RTN);
  7517.                     if RTN /= 0 then
  7518.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7519.                     "internal error when reading COMPONENT from ADARECORD");
  7520.                         raise LL_DAMES.X_INTERNAL_ERROR;
  7521.                     end if;
  7522.                     COMPONENT:= CONVERSION.ADA_STRING (VALUE, FALSE)
  7523.                                                 (1 .. NAME_LENGTH);
  7524.  
  7525.                     EOF := FALSE;
  7526.                     return;
  7527.                 end if;
  7528.  
  7529.                 ADA_GETT (DESCR, TIDD, RTN);
  7530.             end loop;
  7531.         end if;
  7532.         EOF := TRUE;
  7533.     end GET_RECORD;
  7534.  
  7535.  
  7536.                           --------------
  7537.                           -- GET_ENUM --
  7538.                           --------------
  7539.     procedure GET_ENUM (COLNAME      : out STRING;
  7540.                         VALUE        : out INTEGER;
  7541.                         IMAGE_STRING : out STRING;
  7542.                         EOF          : out BOOLEAN) is
  7543.         FTYP, LENR, ATIDX, RTN : INTEGER;
  7544.         VALUE2                 : INTEGER_ARRAY_TYPE (1 .. (IMAGE_SZ + 3)/4);
  7545.     begin
  7546.         if TABLES_EXIST then
  7547.             ADA_GETT (DESCR, TIDD, RTN);
  7548.             ADA_SRCHA (DESCR, "TABLENAME ", ATIDX);
  7549.  
  7550.             while RTN = 0 loop
  7551.                 ADA_GETA (DESCR, ATIDX, VALUE2 (1 .. 3), LENR, FTYP, RTN);
  7552.                 if RTN /= 0 then
  7553.                     UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7554.                     "internal error when reading TABLENAME from ADAENUM");
  7555.                     raise LL_DAMES.X_INTERNAL_ERROR;
  7556.                 end if;
  7557.  
  7558.                 if CONVERSION.ADA_STRING (VALUE2(1 .. 3), FALSE) (1 .. NAME_LENGTH)
  7559.                                     = ACTUAL_USER_TABLE_NAME then
  7560.  
  7561.                         -- get the name of the concerned column
  7562.                     ADA_SRCHA (DESCR, "COLNAME   ", ATIDX);
  7563.                     ADA_GETA (DESCR, ATIDX, VALUE2(1 .. 3), LENR, FTYP, RTN);
  7564.                     if RTN /= 0 then
  7565.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7566.                         "internal error when reading COLNAME from ADAENUM");
  7567.                         raise LL_DAMES.X_INTERNAL_ERROR;
  7568.                     end if;
  7569.                     COLNAME:= CONVERSION.ADA_STRING (VALUE2(1..3), FALSE)
  7570.                                                 (1 .. NAME_LENGTH);
  7571.  
  7572.                         -- get the value of the considered item
  7573.                     ADA_SRCHA (DESCR, "VALUE     ", ATIDX);
  7574.                     ADA_GETA (DESCR, ATIDX, VALUE2(1 .. 1), LENR, FTYP, RTN);
  7575.                     if RTN /= 0 then
  7576.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7577.                         "internal error when reading VALUE from ADAENUM");
  7578.                         raise LL_DAMES.X_INTERNAL_ERROR;
  7579.                     end if;
  7580.                     VALUE := VALUE2 (1);
  7581.  
  7582.                         -- get the image of the considered item
  7583.                     VALUE2 := (others => 0);
  7584.                     ADA_SRCHA (DESCR, "IMAGE     ", ATIDX);
  7585.                     ADA_GETA (DESCR, ATIDX, VALUE2, LENR, FTYP, RTN);
  7586.                     if RTN /= 0 then
  7587.                         UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7588.                         "internal error when reading IMAGE from ADAENUM");
  7589.                         raise LL_DAMES.X_INTERNAL_ERROR;
  7590.                     end if;
  7591.                     IMAGE_STRING := CONVERSION.ADA_STRING (VALUE2, FALSE)
  7592.                                                 (1 .. IMAGE_SZ);
  7593.                     EOF := FALSE;
  7594.                     return;
  7595.                 end if;
  7596.  
  7597.                 ADA_GETT (DESCR, TIDD, RTN);
  7598.             end loop;
  7599.         end if;
  7600.         EOF := TRUE;
  7601.     end GET_ENUM;
  7602.  
  7603.                           ---------------
  7604.                           -- PUT_RANGE --
  7605.                           ---------------
  7606.     procedure PUT_RANGE (COLNAME : STRING; MINVALUE, MAXVALUE : STRING) is
  7607.         ATTINX, RTN : INTEGER;
  7608.     begin
  7609.  
  7610.                 -- build the temporary row
  7611.         ADA_SRCHA (RANGE_DESCR, "TABLENAME ", ATTINX);
  7612.         ADA_PUTA (RANGE_DESCR, ATTINX,
  7613.                 CONVERSION.F77_STRING (ACTUAL_USER_TABLE_NAME), -1, RTN);
  7614.         if RTN /= 0 then
  7615.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7616.             "internal error when writting TABLENAME into ADARANGE");
  7617.             raise LL_DAMES.X_INTERNAL_ERROR;
  7618.         end if;
  7619.  
  7620.         ADA_SRCHA (RANGE_DESCR, "COLNAME   ", ATTINX);
  7621.         ADA_PUTA (RANGE_DESCR, ATTINX,
  7622.                 CONVERSION.F77_STRING (COLNAME), -1, RTN);
  7623.         if RTN /= 0 then
  7624.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7625.             "internal error when writting COLNAME into ADARANGE");
  7626.             raise LL_DAMES.X_INTERNAL_ERROR;
  7627.         end if;
  7628.  
  7629.         ADA_SRCHA (RANGE_DESCR, "MINVALUE  ", ATTINX);
  7630.         ADA_PUTA (RANGE_DESCR, ATTINX,
  7631.                 CONVERSION.F77_STRING (MINVALUE), -1, RTN);
  7632.         if RTN /= 0 then
  7633.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7634.             "internal error when writting MINVALUE into ADARANGE");
  7635.             raise LL_DAMES.X_INTERNAL_ERROR;
  7636.         end if;
  7637.  
  7638.         ADA_SRCHA (RANGE_DESCR, "MAXVALUE  ", ATTINX);
  7639.         ADA_PUTA (RANGE_DESCR, ATTINX,
  7640.                 CONVERSION.F77_STRING (MAXVALUE), -1, RTN);
  7641.         if RTN /= 0 then
  7642.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7643.             "internal error when writting MAXVALUE into ADARANGE");
  7644.             raise LL_DAMES.X_INTERNAL_ERROR;
  7645.         end if;
  7646.  
  7647.  
  7648.         ADA_INSRTT (RANGE_DESCR, RANGE_TIDD, RTN);
  7649.                 -- add it to the table
  7650.         if RTN /= 0 then
  7651.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7652.             "internal error when adding a row to ADARANGE");
  7653.             raise LL_DAMES.X_INTERNAL_ERROR;
  7654.         end if;
  7655.  
  7656.     end PUT_RANGE;
  7657.  
  7658.  
  7659.                          ----------------
  7660.                          -- PUT_RECORD --
  7661.                          ----------------
  7662.     procedure PUT_RECORD (RECORD_NAME, COMPONENT : STRING) is
  7663.         ATTINX, RTN : INTEGER;     begin
  7664.  
  7665.                 -- build the temporary row
  7666.         ADA_SRCHA (RECORD_DESCR, "TABLENAME ", ATTINX);
  7667.         ADA_PUTA (RECORD_DESCR, ATTINX,
  7668.                 CONVERSION.F77_STRING (ACTUAL_USER_TABLE_NAME), -1, RTN);
  7669.         if RTN /= 0 then
  7670.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7671.             "internal error when writting TABLENAME into ADARECORD");
  7672.             raise LL_DAMES.X_INTERNAL_ERROR;
  7673.         end if;
  7674.  
  7675.         ADA_SRCHA (RECORD_DESCR, "RECORDNAME", ATTINX);
  7676.         ADA_PUTA (RECORD_DESCR, ATTINX,
  7677.                 CONVERSION.F77_STRING (RECORD_NAME), -1, RTN);
  7678.         if RTN /= 0 then
  7679.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7680.             "internal error when writting RECORDNAME into ADARECORD");
  7681.             raise LL_DAMES.X_INTERNAL_ERROR;
  7682.         end if;
  7683.  
  7684.         ADA_SRCHA (RECORD_DESCR, "COMPONENT ", ATTINX);
  7685.         ADA_PUTA (RECORD_DESCR, ATTINX,
  7686.                 CONVERSION.F77_STRING (COMPONENT), -1, RTN);
  7687.         if RTN /= 0 then
  7688.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7689.             "internal error when writting COMPONENT into ADARECORD");
  7690.             raise LL_DAMES.X_INTERNAL_ERROR;
  7691.         end if;
  7692.  
  7693.         ADA_INSRTT (RECORD_DESCR, RECORD_TIDD, RTN);
  7694.         if RTN /= 0 then
  7695.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7696.             "internal error when adding a row to ADARECORD");
  7697.             raise LL_DAMES.X_INTERNAL_ERROR;
  7698.         end if;
  7699.     end PUT_RECORD;
  7700.  
  7701.  
  7702.                           --------------
  7703.                           -- PUT_ENUM --
  7704.                           --------------
  7705.     procedure PUT_ENUM (COLNAME      : STRING;
  7706.                         VALUE        : INTEGER;
  7707.                         IMAGE_STRING : STRING) is
  7708.         ATTINX, RTN : INTEGER;
  7709.         VALUE2 : INTEGER_ARRAY_TYPE (1 .. 1);
  7710.     begin
  7711.  
  7712.                 -- build the temporary row
  7713.         ADA_SRCHA (ENUM_DESCR, "TABLENAME ", ATTINX);
  7714.         ADA_PUTA (ENUM_DESCR, ATTINX,
  7715.                 CONVERSION.F77_STRING (ACTUAL_USER_TABLE_NAME), -1, RTN);
  7716.         if RTN /= 0 then
  7717.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7718.             "internal error when writting TABLENAME into ADAENUM");
  7719.             raise LL_DAMES.X_INTERNAL_ERROR;
  7720.         end if;
  7721.         ADA_SRCHA (ENUM_DESCR, "COLNAME   ", ATTINX);
  7722.         ADA_PUTA (ENUM_DESCR, ATTINX,
  7723.                 CONVERSION.F77_STRING (COLNAME), -1, RTN);
  7724.         if RTN /= 0 then
  7725.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7726.             "internal error when writting COLNAME into ADAENUM");
  7727.             raise LL_DAMES.X_INTERNAL_ERROR;
  7728.         end if;
  7729.  
  7730.         VALUE2 (1) := VALUE;
  7731.         ADA_SRCHA (ENUM_DESCR, "VALUE     ", ATTINX);
  7732.         ADA_PUTA (ENUM_DESCR, ATTINX,
  7733.                 VALUE2, -1, RTN);
  7734.         if RTN /= 0 then
  7735.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7736.             "internal error when writting VALUE into ADAENUM");
  7737.             raise LL_DAMES.X_INTERNAL_ERROR;
  7738.         end if;
  7739.  
  7740.         ADA_SRCHA (ENUM_DESCR, "IMAGE     ", ATTINX);
  7741.         ADA_PUTA (ENUM_DESCR, ATTINX,
  7742.                 CONVERSION.F77_STRING (IMAGE_STRING), -1, RTN);
  7743.         if RTN /= 0 then
  7744.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7745.             "internal error when writting IMAGE into ADAENUM");
  7746.             raise LL_DAMES.X_INTERNAL_ERROR;
  7747.         end if;
  7748.  
  7749.         ADA_INSRTT (ENUM_DESCR, ENUM_TIDD, RTN);
  7750.         if RTN /= 0 then
  7751.             UTILITIES.OUTPUT_MESSAGE ("Ada interface : " &
  7752.             "internal error when adding a row to ADAENUM");
  7753.             raise LL_DAMES.X_INTERNAL_ERROR;
  7754.         end if;
  7755.     end PUT_ENUM;
  7756.  
  7757.  
  7758.  
  7759.                        ---------------------
  7760.                        -- CLOSE_ADA_TABLE --
  7761.                        ---------------------
  7762.     procedure CLOSE_ADA_TABLE is
  7763.         RTN : INTEGER;
  7764.     begin
  7765.       if TABLES_EXIST then
  7766.         ADA_CLOSER (DESCR);
  7767.       end if;
  7768.     end CLOSE_ADA_TABLE;
  7769.  
  7770.  
  7771.  
  7772.                       -----------------------
  7773.                       -- UNLOCK_ADA_TABLES --
  7774.                       -----------------------
  7775.     procedure UNLOCK_ADA_TABLES is
  7776.     begin
  7777.         ADA_CLRELS;
  7778.         ADA_DUNLK;
  7779.     end UNLOCK_ADA_TABLES;
  7780.  
  7781. end ADA_TABLES;
  7782. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  7783. --parse.txt
  7784. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  7785. with CONSTANTS;
  7786. use CONSTANTS;
  7787.  
  7788. with F77_CALLABLES;
  7789.  
  7790. with ADA_TABLES;
  7791.  
  7792. package body PARSE is
  7793.  
  7794.     CURRENT : POSITIVE;
  7795.         -- this index will be used as a pointer to the character
  7796.         -- being currently analysed
  7797.  
  7798.  
  7799.                             -----------
  7800.                             -- ERROR --
  7801.                             -----------
  7802.     procedure ERROR is
  7803.         -- ERROR is called when a syntax error is found
  7804.  
  7805.     begin
  7806.         raise X_SYNTAX_ERROR;
  7807.     end ERROR;
  7808.  
  7809.  
  7810.                          ----------------
  7811.                          -- UPPER_CASE --
  7812.                          ----------------
  7813.     procedure UPPER_CASE (TEXT : in out STRING) is
  7814.         -- UPPER_CASE is used to change in situ all lower_case letters
  7815.         -- of TEXT into their upper_case equivalent
  7816.     begin
  7817.         for I in 1 .. TEXT'LENGTH loop
  7818.             if TEXT (I) >= 'a' then
  7819.                 TEXT (I) := CHARACTER'VAL (CHARACTER'POS (TEXT (I)) - 32);
  7820.             end if;
  7821.         end loop;
  7822.     end UPPER_CASE;
  7823.  
  7824.  
  7825.                       -----------------------
  7826.                       -- PARSE_FIRST_LEVEL --
  7827.                       -----------------------
  7828.     procedure PARSE_FIRST_LEVEL (COLUMN_LIST : STRING; RCKEY : INTEGER) is
  7829.  
  7830.         COLUMN_NAME : STRING (1 .. 12);
  7831.         COLUMN_TYPE : INTEGER;
  7832.         COLUMN_LENGTH : INTEGER;
  7833.         DOMAIN_NAME : constant STRING :=
  7834.                          (1 .. 4 => ASCII.NUL, 5 .. 12 => ' ');
  7835.         RTN : INTEGER;
  7836.             -- these five items and RCKEY are the arguments of the
  7837.             -- ADDATR access procedure; they are filled during the
  7838.             -- parsing of COLUMN_LIST.
  7839.  
  7840.         COLUMN_LIST_COPY : STRING (1 .. COLUMN_LIST'LENGTH + 8);
  7841.             -- a significantly longer string than COLUMN_LIST is needed
  7842.             -- in order to analyse COLUMN_LIST without risk for
  7843.             -- constraint_error due to the index, and in order too to
  7844.             -- append a particular symbol (here a '$') at the end of the
  7845.             -- sentence to be analysed.
  7846.  
  7847.                           --------------
  7848.                           -- IS_RANGE --
  7849.                           --------------
  7850.         function IS_RANGE return BOOLEAN is
  7851.             -- return TRUE if the current token is the keyword RANGE,
  7852.             -- and FALSE otherwise.
  7853.  
  7854.         begin
  7855.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 4) = "RANGE" then
  7856.                 return TRUE;
  7857.             else
  7858.                 return FALSE;
  7859.             end if;
  7860.         end IS_RANGE;
  7861.  
  7862.  
  7863.                           ---------------
  7864.                           -- IS_STRING --
  7865.                           ---------------
  7866.         function IS_STRING return BOOLEAN is
  7867.             -- return TRUE if the current token is the keyword STRING,
  7868.             -- and FALSE otherwise.
  7869.  
  7870.         begin
  7871.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 5) = "STRING" and
  7872.                COLUMN_LIST_COPY (CURRENT + 6) /= '.' and
  7873.                COLUMN_LIST_COPY (CURRENT + 6) /= '=' and
  7874.                COLUMN_LIST_COPY (CURRENT + 6) /= '_' and
  7875.                (COLUMN_LIST_COPY (CURRENT + 6) < 'A' or
  7876.                 COLUMN_LIST_COPY (CURRENT + 6) > 'Z') and
  7877.                (COLUMN_LIST_COPY (CURRENT + 6) < '0' or
  7878.                 COLUMN_LIST_COPY (CURRENT + 6) > '9') then
  7879.                 return TRUE;
  7880.             else
  7881.                 return FALSE;
  7882.             end if;
  7883.         end IS_STRING;
  7884.  
  7885.  
  7886.                           --------------
  7887.                           -- IS_FLOAT --
  7888.                           --------------
  7889.         function IS_FLOAT return BOOLEAN is
  7890.             -- return TRUE if the current token is the keyword FLOAT,
  7891.             -- and FALSE otherwise.
  7892.  
  7893.         begin
  7894.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 4) = "FLOAT" and
  7895.                COLUMN_LIST_COPY (CURRENT + 5) /= '.' and
  7896.                COLUMN_LIST_COPY (CURRENT + 5) /= '=' and
  7897.                COLUMN_LIST_COPY (CURRENT + 5) /= '_' and
  7898.                (COLUMN_LIST_COPY (CURRENT + 5) < 'A' or
  7899.                 COLUMN_LIST_COPY (CURRENT + 5) > 'Z') and
  7900.                (COLUMN_LIST_COPY (CURRENT + 5) < '0' or
  7901.                 COLUMN_LIST_COPY (CURRENT + 5) > '9') then
  7902.                 return TRUE;
  7903.             else
  7904.                 return FALSE;
  7905.             end if;
  7906.         end IS_FLOAT;
  7907.  
  7908.                          ----------------
  7909.                          -- IS_INTEGER --
  7910.                          ----------------
  7911.         function IS_INTEGER return BOOLEAN is
  7912.             -- return TRUE if the current token is the keyword INTEGER,
  7913.             -- and FALSE otherwise.
  7914.  
  7915.         begin
  7916.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 6) = "INTEGER" and
  7917.                COLUMN_LIST_COPY (CURRENT + 7) /= '.' and
  7918.                COLUMN_LIST_COPY (CURRENT + 7) /= '=' and
  7919.                COLUMN_LIST_COPY (CURRENT + 7) /= '_' and
  7920.                (COLUMN_LIST_COPY (CURRENT + 7) < 'A' or
  7921.                 COLUMN_LIST_COPY (CURRENT + 7) > 'Z') and
  7922.                (COLUMN_LIST_COPY (CURRENT + 7) < '0' or
  7923.                 COLUMN_LIST_COPY (CURRENT + 7) > '9') then
  7924.                 return TRUE;
  7925.             else
  7926.                 return FALSE;
  7927.             end if;
  7928.         end IS_INTEGER;
  7929.  
  7930.  
  7931.                      -----------------------
  7932.                      -- IS_NATURAL_NUMBER --
  7933.                      -----------------------
  7934.         function IS_NATURAL_NUMBER return BOOLEAN is
  7935.             -- return TRUE if the current token is a natural number,
  7936.             -- and FALSE otherwise.
  7937.  
  7938.         begin
  7939.             if COLUMN_LIST_COPY (CURRENT) >= '0' and
  7940.                COLUMN_LIST_COPY (CURRENT) <= '9' then
  7941.                 return TRUE;
  7942.             else
  7943.                 return FALSE;
  7944.             end if;
  7945.         end IS_NATURAL_NUMBER;
  7946.  
  7947.  
  7948.  
  7949.                           --------------
  7950.                           -- GO_AHEAD --
  7951.                           --------------
  7952.         procedure GO_AHEAD is
  7953.             -- jump to the following token.
  7954.  
  7955.         begin
  7956.             CURRENT := CURRENT + 1;
  7957.  
  7958.             while COLUMN_LIST_COPY (CURRENT) /= ' ' and
  7959.                   COLUMN_LIST_COPY (CURRENT) /= ';' and
  7960.                   COLUMN_LIST_COPY (CURRENT) /= '$' and
  7961.                   COLUMN_LIST_COPY (CURRENT) /= ',' and
  7962.                   COLUMN_LIST_COPY (CURRENT) /= '(' and
  7963.                   COLUMN_LIST_COPY (CURRENT) /= ')' and
  7964.                   COLUMN_LIST_COPY (CURRENT .. CURRENT + 1) /= ".." loop
  7965.                 CURRENT := CURRENT + 1;
  7966.             end loop;
  7967.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  7968.                 CURRENT := CURRENT + 1;
  7969.             end loop;
  7970.         end GO_AHEAD;
  7971.  
  7972.  
  7973.                             -----------
  7974.                             -- VALUE --
  7975.                             -----------
  7976.         procedure VALUE is
  7977.             -- VALUE recognizes a value of a range constraint.
  7978.  
  7979.         begin
  7980.             GO_AHEAD;
  7981.         end VALUE;
  7982.  
  7983.  
  7984.                          -----------------
  7985.                          -- TWO_PERIODS --
  7986.                          -----------------
  7987.         procedure TWO_PERIODS is
  7988.             -- TWO_PERIODS recognizes the two periods between the two
  7989.             -- values of a range constraint.
  7990.  
  7991.         begin
  7992.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 1) = ".." then
  7993.                 CURRENT := CURRENT + 2;
  7994.                 while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  7995.                     CURRENT := CURRENT + 1;
  7996.                 end loop;
  7997.  
  7998.             else
  7999.                 ERROR;
  8000.             end if;
  8001.         end TWO_PERIODS;
  8002.  
  8003.  
  8004.                          ----------------
  8005.                          -- CONSTRAINT --
  8006.                          ----------------
  8007.         procedure CONSTRAINT is
  8008.             -- CONSTRAINT recognizes a range constraint.
  8009.  
  8010.         begin
  8011.             if IS_RANGE then
  8012.                 GO_AHEAD;
  8013.                 VALUE;
  8014.                 TWO_PERIODS;
  8015.                 VALUE;
  8016.             end if;
  8017.         end CONSTRAINT;
  8018.  
  8019.                  --------------------------------
  8020.                  -- INDEX_CONSTRAINT_BEGINNING --
  8021.                  --------------------------------
  8022.         procedure INDEX_CONSTRAINT_BEGINNING is
  8023.             -- INDEX_CONSTRAINT_BEGINNING recognizes the beginning of a
  8024.             -- size specification for a character string, i.e. the
  8025.             -- following items :
  8026.             --          (1..
  8027.             -- which are normally followed by a positive number and a
  8028.             -- right parenthesis, such as :
  8029.             --          (1..n)
  8030.  
  8031.         begin
  8032.             CURRENT := CURRENT + 1;
  8033.  
  8034.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8035.                 CURRENT := CURRENT + 1;
  8036.             end loop;
  8037.  
  8038.             if COLUMN_LIST_COPY (CURRENT) = '1' then
  8039.                 CURRENT := CURRENT + 1;
  8040.             else
  8041.                 ERROR;
  8042.             end if;
  8043.  
  8044.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8045.                 CURRENT := CURRENT + 1;
  8046.             end loop;
  8047.  
  8048.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 1) = ".." then
  8049.                 CURRENT := CURRENT + 2;
  8050.             else
  8051.                 ERROR;
  8052.             end if;
  8053.  
  8054.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8055.                 CURRENT := CURRENT + 1;
  8056.             end loop;
  8057.         end INDEX_CONSTRAINT_BEGINNING;
  8058.  
  8059.  
  8060.  
  8061.                       -----------------------
  8062.                       -- RIGHT_PARENTHESIS --
  8063.                       -----------------------
  8064.         procedure RIGHT_PARENTHESIS is
  8065.             -- recognize a right parenthesis
  8066.  
  8067.         begin
  8068.             if COLUMN_LIST_COPY (CURRENT) = ')' then
  8069.                 GO_AHEAD;
  8070.             else
  8071.                 ERROR;
  8072.             end if;
  8073.         end RIGHT_PARENTHESIS;
  8074.  
  8075.                          ----------------
  8076.                          -- ENUM_IMAGE --
  8077.                          ----------------
  8078.         procedure ENUM_IMAGE is
  8079.             -- ENUM_IMAGE recognizes an item of an enumeration list;
  8080.             -- in fact, it accepts any word composed of letters, digits
  8081.             -- and underscores, without taking care of their order (for
  8082.             -- instance, a word beginning with an underscore or a digit
  8083.             -- will be accepted, another containing two consecutive
  8084.             -- underscores will be accepted too).
  8085.  
  8086.             SAVE_CURRENT : POSITIVE;
  8087.  
  8088.         begin
  8089.             SAVE_CURRENT := CURRENT;
  8090.  
  8091.             while COLUMN_LIST_COPY (CURRENT) = '_' or
  8092.                   (COLUMN_LIST_COPY (CURRENT) >= '0' and
  8093.                    COLUMN_LIST_COPY (CURRENT) <= '9') or
  8094.                   (COLUMN_LIST_COPY (CURRENT) >= 'A' and
  8095.                    COLUMN_LIST_COPY (CURRENT) <= 'Z') loop
  8096.                 CURRENT := CURRENT + 1;
  8097.             end loop;
  8098.  
  8099.             if CURRENT - SAVE_CURRENT > IMAGE_SZ then
  8100.                     -- more than IMAGE_SZ characters long image
  8101.  
  8102.                 COLUMN_LENGTH := IMAGE_SZ;
  8103.             else
  8104.                     -- one to IMAGE_SZ characters long image
  8105.  
  8106.                 if CURRENT - SAVE_CURRENT > COLUMN_LENGTH then
  8107.                         -- the currently recognized image is the longest
  8108.                         -- of those which have been recognized before.
  8109.  
  8110.                     COLUMN_LENGTH := CURRENT - SAVE_CURRENT;
  8111.                 end if;
  8112.             end if;
  8113.  
  8114.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8115.                 CURRENT := CURRENT + 1;
  8116.             end loop;
  8117.         end ENUM_IMAGE;
  8118.  
  8119.  
  8120.                         ------------------
  8121.                         -- SCALAR_DESCR --
  8122.                         ------------------
  8123.         procedure SCALAR_DESCR is
  8124.             -- SCALAR_DESCR recognizes a scalar type, i.e. :
  8125.             --  STRING (1 .. 10) by default;
  8126.             --  STRING (1 .. n);
  8127.             --  FLOAT;
  8128.             --  INTEGER (n bytes wide, n being specified, or being
  8129.             --          chosen to 4 by default);
  8130.             --  an enumeration type, defined by items enclosed in
  8131.             --          parentheses.
  8132.             -- Each of these types can have a range constraint, which
  8133.             -- is recognized by the above defined CONSTRAINT procedure,
  8134.             -- except the STRING type.
  8135.             RECOGNIZED_NUMBER : INTEGER;
  8136.                 -- RECOGNIZED_NUMBER is a number recognized by
  8137.                 -- NATURAL_NUMBER and used as string or integer length
  8138.  
  8139.  
  8140.                        --------------------
  8141.                        -- NATURAL_NUMBER --
  8142.                        --------------------
  8143.             procedure NATURAL_NUMBER is
  8144.                 -- recognize a natural number
  8145.  
  8146.                 SAVE_CURRENT : POSITIVE;
  8147.  
  8148.             begin
  8149.                 SAVE_CURRENT := CURRENT;
  8150.  
  8151.                 while COLUMN_LIST_COPY (CURRENT) >= '0' and
  8152.                       COLUMN_LIST_COPY (CURRENT) <= '9' loop
  8153.                     CURRENT := CURRENT + 1;
  8154.                 end loop;
  8155.  
  8156.                         -- store the recognized number in RECOGNIZED_NUMBER
  8157.                 RECOGNIZED_NUMBER := INTEGER'VALUE
  8158.                         (COLUMN_LIST_COPY (SAVE_CURRENT .. CURRENT - 1));
  8159.  
  8160.                 while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8161.                     CURRENT := CURRENT + 1;
  8162.                 end loop;
  8163.             end NATURAL_NUMBER;
  8164.  
  8165.         begin
  8166.             if IS_STRING then
  8167.                         -- the type is a STRING type
  8168.  
  8169.                 GO_AHEAD;
  8170.  
  8171.                         -- store 5 in COLUMN_TYPE to denote a STRING
  8172.                 COLUMN_TYPE := 5;
  8173.  
  8174.                 if COLUMN_LIST_COPY (CURRENT) = '(' then
  8175.                         -- this string type has an index constraint
  8176.  
  8177.                     INDEX_CONSTRAINT_BEGINNING;
  8178.                     NATURAL_NUMBER;
  8179.                     RIGHT_PARENTHESIS;
  8180.  
  8181.                         -- store the number recognized by NATURAL_NUMBER
  8182.                         -- in COLUMN_LENGTH
  8183.                     COLUMN_LENGTH := RECOGNIZED_NUMBER;
  8184.  
  8185.                 else
  8186.                         -- store the default length in COLUMN_LENGTH
  8187.                     COLUMN_LENGTH := 10;
  8188.  
  8189.                 end if;
  8190.             elsif IS_FLOAT then
  8191.                         -- the type is a FLOAT type
  8192.  
  8193.                 GO_AHEAD;
  8194.  
  8195.                         -- store 2 in COLUMN_TYPE to denote FLOAT
  8196.                 COLUMN_TYPE := 2;
  8197.  
  8198.                         -- store the float length in COLUMN_LENGTH
  8199.                 COLUMN_LENGTH := 4;
  8200.  
  8201.                 CONSTRAINT;
  8202.  
  8203.             elsif IS_INTEGER then
  8204.                         -- the type is an INTEGER type
  8205.  
  8206.                 GO_AHEAD;
  8207.  
  8208.                         -- store 1 in COLUMN_TYPE to denote an INTEGER
  8209.                 COLUMN_TYPE := 1;
  8210.  
  8211.                 COLUMN_LENGTH := 4;
  8212.  
  8213. --------------------------------------------------------------------------
  8214. --
  8215. --      Following comments must be executed if the byte length of
  8216. -- INTEGER type can be chosen; otherwise, 32 bits is chosen for
  8217. -- default length.
  8218. --
  8219. --if IS_NATURAL_NUMBER then
  8220. --      -- this INTEGER type has a size specification
  8221. --
  8222. --    NATURAL_NUMBER;
  8223. --
  8224. --      -- store in COLUMN_LENGTH the size (in bytes)
  8225. --      -- recognized by NATURAL_NUMBER (size in bytes)
  8226. --    COLUMN_LENGTH := RECOGNIZED_NUMBER;
  8227. --
  8228. --else
  8229. --      -- store in COLUMN_LENGTH the default size
  8230. --    COLUMN_LENGTH := 4;
  8231. --end if;
  8232. --
  8233. --------------------------------------------------------------------------
  8234.  
  8235.                 CONSTRAINT;
  8236.  
  8237.             elsif COLUMN_LIST_COPY (CURRENT) = '(' then
  8238.                         -- the type is an enumeration type
  8239.  
  8240.                 CURRENT := CURRENT + 1;
  8241.  
  8242.                 while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8243.                     CURRENT := CURRENT + 1;
  8244.                 end loop;
  8245.  
  8246.                 COLUMN_LENGTH := 1;
  8247.                         -- the COLUMN_LENGTH variable will be updated
  8248.                         -- by the ENUM_IMAGE call's up to the greater
  8249.                         -- length of all images of the enumeration type
  8250.                         -- currently recognized.
  8251.                 ENUM_IMAGE;
  8252.                         -- recognize the first item
  8253.  
  8254.                 while COLUMN_LIST_COPY (CURRENT) = ',' loop
  8255.                         -- than recognize each of the following items
  8256.  
  8257.                     CURRENT := CURRENT + 1;
  8258.  
  8259.                     while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8260.                         CURRENT := CURRENT + 1;
  8261.                     end loop;
  8262.  
  8263.                     ENUM_IMAGE;
  8264.                 end loop;
  8265.  
  8266.                 if COLUMN_LIST_COPY (CURRENT) = ')' then
  8267.                         -- check that the enumeration list ends with a
  8268.                         -- right parenthesis.
  8269.  
  8270.                     CURRENT := CURRENT + 1;
  8271.  
  8272.                     while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8273.                         CURRENT := CURRENT + 1;
  8274.                     end loop;
  8275.                 else
  8276.                         -- the enumeration list does not end with a
  8277.                         -- right parenthesis.
  8278.  
  8279.                     ERROR;
  8280.                 end if;
  8281.  
  8282.                         -- store 5 in COLUMN_TYPE to denote a STRING
  8283.                 COLUMN_TYPE := 5;
  8284.                         -- the length has been stored in COLUMN_LENGTH
  8285.                         -- by the previous calls to ENUM_IMAGE
  8286.  
  8287.                 CONSTRAINT;
  8288.             else
  8289.                     -- the type is a character string 10 characters long
  8290.  
  8291.                 COLUMN_TYPE := 5;
  8292.                 COLUMN_LENGTH := 10;
  8293.             end if;
  8294.  
  8295.                 -- let's add the recognized attribute to the table being
  8296.                 -- created :
  8297.             F77_CALLABLES.ADA_ADDATR (RCKEY,
  8298.                                       COLUMN_NAME,
  8299.                                       COLUMN_TYPE,
  8300.                                       COLUMN_LENGTH,
  8301.                                       DOMAIN_NAME,
  8302.                                       RTN);
  8303.             if RTN /= 0 then
  8304.                 ERROR;
  8305.             end if;
  8306.  
  8307.         end SCALAR_DESCR;
  8308.  
  8309.                             ----------
  8310.                             -- NAME --
  8311.                             ----------
  8312.         procedure NAME is
  8313.                 -- NAME recognizes a column name (either an Ada or a
  8314.                 -- DAMES column, since Ada record columns are composed
  8315.                 -- of several DAMES columns, one for each component).
  8316.                 -- Such an identifier must begin with a letter, which
  8317.                 -- is followed by other letters, digits, periods,
  8318.                 -- equal signs, or underscores.
  8319.  
  8320.             SAVE_CURRENT : POSITIVE;
  8321.  
  8322.         begin
  8323.             if COLUMN_LIST_COPY (CURRENT) >= 'A' and
  8324.                COLUMN_LIST_COPY (CURRENT) <= 'Z' then
  8325.                 
  8326.                 SAVE_CURRENT := CURRENT;
  8327.                 CURRENT := CURRENT + 1;
  8328.  
  8329.                 while (COLUMN_LIST_COPY (CURRENT) >= 'A' and
  8330.                        COLUMN_LIST_COPY (CURRENT) <= 'Z') or
  8331.                       (COLUMN_LIST_COPY (CURRENT) >= '0' and
  8332.                        COLUMN_LIST_COPY (CURRENT) <= '9') or
  8333.                       COLUMN_LIST_COPY (CURRENT) = '_' or
  8334.                       COLUMN_LIST_COPY (CURRENT) = '.' or
  8335.                       COLUMN_LIST_COPY (CURRENT) = '=' loop
  8336.                     CURRENT := CURRENT + 1;
  8337.                 end loop;
  8338.  
  8339.                         -- store now in COLUMN_NAME the recognized name
  8340.                 if CURRENT - SAVE_CURRENT < 11 then
  8341.                         -- one to ten characters long name
  8342.                     COLUMN_NAME :=
  8343.                         COLUMN_LIST_COPY (SAVE_CURRENT .. CURRENT - 1)
  8344.                         &      (CURRENT - SAVE_CURRENT + 1 .. 12 => ' ');
  8345.                 else
  8346.                         -- more than ten characters long name
  8347.                     COLUMN_NAME := COLUMN_LIST_COPY
  8348.                         (SAVE_CURRENT .. SAVE_CURRENT + 9) & "  ";
  8349.                 end if;
  8350.  
  8351.                 while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8352.                     CURRENT := CURRENT + 1;
  8353.                 end loop;
  8354.             else
  8355.                     -- the current token does not begin with a letter
  8356.  
  8357.                 ERROR;
  8358.             end if;
  8359.         end NAME;
  8360.  
  8361.  
  8362.                        ---------------------
  8363.                        -- IS_SCALAR_DESCR --
  8364.                        ---------------------
  8365.         function IS_SCALAR_DESCR return BOOLEAN is
  8366.                 -- IS_SCALAR_DESCR returns TRUE if the current token is
  8367.                 -- the beginning of a type specification, and returns
  8368.                 -- FALSE otherwise (if the sentence is syntactically
  8369.                 -- correct, it means the token is a column name).
  8370.         begin
  8371.             if COLUMN_LIST_COPY (CURRENT) = ',' or
  8372.                COLUMN_LIST_COPY (CURRENT) = ';' or
  8373.                COLUMN_LIST_COPY (CURRENT) = '$' or
  8374.                IS_STRING or
  8375.                IS_FLOAT or IS_INTEGER or COLUMN_LIST_COPY (CURRENT) = '(' then
  8376.                 return TRUE;
  8377.             else
  8378.                 return FALSE;
  8379.             end if;
  8380.         end IS_SCALAR_DESCR;
  8381.  
  8382.  
  8383.  
  8384.                         ------------------
  8385.                         -- COLUMN_DESCR --
  8386.                         ------------------
  8387.         procedure COLUMN_DESCR is
  8388.                 -- COLUMN_DESCR recognizes a column descriptor, which
  8389.                 -- is a column name followed by a scalar descriptor
  8390.                 -- or a record descriptor.
  8391.  
  8392.         begin
  8393.             NAME;
  8394.  
  8395.             if IS_SCALAR_DESCR then
  8396.                 SCALAR_DESCR;
  8397.             else
  8398.                 NAME;
  8399.                 SCALAR_DESCR;
  8400.  
  8401.                 while COLUMN_LIST_COPY (CURRENT) = ',' loop
  8402.                     CURRENT := CURRENT + 1;
  8403.  
  8404.                     while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8405.                         CURRENT := CURRENT + 1;
  8406.                     end loop;
  8407.  
  8408.                     NAME;
  8409.                     SCALAR_DESCR;
  8410.                 end loop;
  8411.             end if;
  8412.         end COLUMN_DESCR;     begin
  8413.         COLUMN_LIST_COPY := COLUMN_LIST & "$       ";
  8414.         UPPER_CASE (COLUMN_LIST_COPY);
  8415.         CURRENT := 1;
  8416.  
  8417.         while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8418.             CURRENT := CURRENT + 1;
  8419.         end loop;
  8420.  
  8421.         COLUMN_DESCR;
  8422.  
  8423.         while COLUMN_LIST_COPY (CURRENT) = ';' loop
  8424.             CURRENT := CURRENT + 1;
  8425.  
  8426.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8427.                 CURRENT := CURRENT + 1;
  8428.             end loop;
  8429.  
  8430.             COLUMN_DESCR;
  8431.         end loop;
  8432.         
  8433.         if COLUMN_LIST_COPY (CURRENT) /= '$' then
  8434.             ERROR;
  8435.         end if;
  8436.         
  8437.     end PARSE_FIRST_LEVEL;
  8438.  
  8439.  
  8440.  
  8441.                      ------------------------
  8442.                      -- PARSE_SECOND_LEVEL --
  8443.                      ------------------------
  8444.     procedure PARSE_SECOND_LEVEL (COLUMN_LIST : STRING) is
  8445.  
  8446.         COLUMN_NAME : STRING (1 .. 12);
  8447.         RECORD_NAME : STRING (1 .. 12) := (others => ' ');
  8448.         MINVALUE, MAXVALUE : STRING (1 .. RANGE_SIZE);
  8449.         ENUM_VALUE : INTEGER;
  8450.         ENUM_LITERAL : STRING (1 .. IMAGE_SZ);
  8451.             -- these six items are the arguments of the ADA_TABLES
  8452.             -- package procedures; they are used to update the three
  8453.             -- reserved tables : ADARANGE, ADARECORD and ADAENUM.
  8454.             -- They are filled during the parsing of COLUMN_LIST.
  8455.  
  8456.         COLUMN_LIST_COPY : STRING (1 .. COLUMN_LIST'LENGTH + 8);
  8457.             -- a significantly longer string than COLUMN_LIST is needed
  8458.             -- in order to analyse COLUMN_LIST without risk for
  8459.             -- constraint_error due to the index, and in order too to
  8460.             -- append a particular symbol (here a '$') at the end of the
  8461.             -- sentence to be analysed.
  8462.  
  8463.  
  8464.                           --------------
  8465.                           -- IS_RANGE --
  8466.                           --------------
  8467.         function IS_RANGE return BOOLEAN is
  8468.             -- return TRUE if the current token is the keyword RANGE,
  8469.             -- and FALSE otherwise.
  8470.  
  8471.         begin
  8472.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 4) = "RANGE" then
  8473.                 return TRUE;
  8474.             else
  8475.                 return FALSE;
  8476.             end if;
  8477.         end IS_RANGE;
  8478.  
  8479.  
  8480.                           ---------------
  8481.                           -- IS_STRING --
  8482.                           ---------------
  8483.         function IS_STRING return BOOLEAN is
  8484.             -- return TRUE if the current token is the keyword STRING,
  8485.             -- and FALSE otherwise.
  8486.  
  8487.         begin
  8488.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 5) = "STRING" and
  8489.                COLUMN_LIST_COPY (CURRENT + 6) /= '.' and
  8490.                COLUMN_LIST_COPY (CURRENT + 6) /= '=' and
  8491.                COLUMN_LIST_COPY (CURRENT + 6) /= '_' and
  8492.                (COLUMN_LIST_COPY (CURRENT + 6) < 'A' or
  8493.                 COLUMN_LIST_COPY (CURRENT + 6) > 'Z') and
  8494.                (COLUMN_LIST_COPY (CURRENT + 6) < '0' or
  8495.                 COLUMN_LIST_COPY (CURRENT + 6) > '9') then
  8496.                 return TRUE;
  8497.             else
  8498.                 return FALSE;
  8499.             end if;
  8500.         end IS_STRING;
  8501.  
  8502.                           --------------
  8503.                           -- IS_FLOAT --
  8504.                           --------------
  8505.         function IS_FLOAT return BOOLEAN is
  8506.             -- return TRUE if the current token is the keyword FLOAT,
  8507.             -- and FALSE otherwise.
  8508.  
  8509.         begin
  8510.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 4) = "FLOAT" and
  8511.                COLUMN_LIST_COPY (CURRENT + 5) /= '.' and
  8512.                COLUMN_LIST_COPY (CURRENT + 5) /= '=' and
  8513.                COLUMN_LIST_COPY (CURRENT + 5) /= '_' and
  8514.                (COLUMN_LIST_COPY (CURRENT + 5) < 'A' or
  8515.                 COLUMN_LIST_COPY (CURRENT + 5) > 'Z') and
  8516.                (COLUMN_LIST_COPY (CURRENT + 5) < '0' or
  8517.                 COLUMN_LIST_COPY (CURRENT + 5) > '9') then
  8518.                 return TRUE;
  8519.             else
  8520.                 return FALSE;
  8521.             end if;
  8522.         end IS_FLOAT;
  8523.  
  8524.  
  8525.                          ----------------
  8526.                          -- IS_INTEGER --
  8527.                          ----------------
  8528.         function IS_INTEGER return BOOLEAN is
  8529.             -- return TRUE if the current token is the keyword INTEGER,
  8530.             -- and FALSE otherwise.
  8531.  
  8532.         begin
  8533.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 6) = "INTEGER" and
  8534.                COLUMN_LIST_COPY (CURRENT + 7) /= '.' and
  8535.                COLUMN_LIST_COPY (CURRENT + 7) /= '=' and
  8536.                COLUMN_LIST_COPY (CURRENT + 7) /= '_' and
  8537.                (COLUMN_LIST_COPY (CURRENT + 7) < 'A' or
  8538.                 COLUMN_LIST_COPY (CURRENT + 7) > 'Z') and
  8539.                (COLUMN_LIST_COPY (CURRENT + 7) < '0' or
  8540.                 COLUMN_LIST_COPY (CURRENT + 7) > '9') then
  8541.                 return TRUE;
  8542.             else
  8543.                 return FALSE;
  8544.             end if;
  8545.         end IS_INTEGER;
  8546.  
  8547.  
  8548.                      -----------------------
  8549.                      -- IS_NATURAL_NUMBER --
  8550.                      -----------------------
  8551.         function IS_NATURAL_NUMBER return BOOLEAN is
  8552.             -- return TRUE if the current token is a natural number,
  8553.             -- and FALSE otherwise.
  8554.  
  8555.         begin
  8556.             if COLUMN_LIST_COPY (CURRENT) >= '0' and
  8557.                COLUMN_LIST_COPY (CURRENT) <= '9' then
  8558.                 return TRUE;
  8559.             else
  8560.                 return FALSE;
  8561.             end if;
  8562.         end IS_NATURAL_NUMBER;
  8563.  
  8564.                           --------------
  8565.                           -- GO_AHEAD --
  8566.                           --------------
  8567.         procedure GO_AHEAD is
  8568.             -- jump to the following token.
  8569.  
  8570.         begin
  8571.             CURRENT := CURRENT + 1;
  8572.  
  8573.             while COLUMN_LIST_COPY (CURRENT) /= ' ' and
  8574.                   COLUMN_LIST_COPY (CURRENT) /= ';' and
  8575.                   COLUMN_LIST_COPY (CURRENT) /= '$' and
  8576.                   COLUMN_LIST_COPY (CURRENT) /= ',' and
  8577.                   COLUMN_LIST_COPY (CURRENT) /= '(' and
  8578.                   COLUMN_LIST_COPY (CURRENT) /= ')' and
  8579.                   COLUMN_LIST_COPY (CURRENT .. CURRENT + 1) /= ".." loop
  8580.                 CURRENT := CURRENT + 1;
  8581.             end loop;
  8582.  
  8583.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8584.                 CURRENT := CURRENT + 1;
  8585.             end loop;
  8586.         end GO_AHEAD;
  8587.  
  8588.  
  8589.                             ---------------
  8590.                             -- VALUE_MIN --
  8591.                             ---------------
  8592.         procedure VALUE_MIN is
  8593.             -- VALUE_MIN recognizes the first value of a range constraint.
  8594.  
  8595.         SAVE_CURRENT : POSITIVE;
  8596.  
  8597.         begin
  8598.             SAVE_CURRENT := CURRENT;
  8599.             CURRENT := CURRENT + 1;
  8600.  
  8601.             while COLUMN_LIST_COPY (CURRENT) /= ' ' and
  8602.                   COLUMN_LIST_COPY (CURRENT) /= ';' and
  8603.                   COLUMN_LIST_COPY (CURRENT) /= '$' and
  8604.                   COLUMN_LIST_COPY (CURRENT) /= ',' and
  8605.                   COLUMN_LIST_COPY (CURRENT) /= '(' and
  8606.                   COLUMN_LIST_COPY (CURRENT) /= ')' and
  8607.                   COLUMN_LIST_COPY (CURRENT .. CURRENT + 1) /= ".." loop
  8608.                 CURRENT := CURRENT + 1;
  8609.             end loop;
  8610.  
  8611.                 -- store now in MINVALUE the recognized value.
  8612.             if CURRENT - SAVE_CURRENT < RANGE_SIZE + 1 then
  8613.                     -- one to RANGE_SIZE characters long value.
  8614.                 MINVALUE :=
  8615.                      COLUMN_LIST_COPY (SAVE_CURRENT .. CURRENT - 1)
  8616.                   &  (CURRENT - SAVE_CURRENT + 1 .. RANGE_SIZE=> ' ');
  8617.             else
  8618.                     -- more than RANGE_SIZE characters long image
  8619.                 MINVALUE := COLUMN_LIST_COPY
  8620.                         (SAVE_CURRENT .. SAVE_CURRENT + RANGE_SIZE - 1);
  8621.             end if;
  8622.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8623.                 CURRENT := CURRENT + 1;
  8624.             end loop;
  8625.         end VALUE_MIN;
  8626.  
  8627.  
  8628.                             ---------------
  8629.                             -- VALUE_MAX --
  8630.                             ---------------
  8631.         procedure VALUE_MAX is
  8632.             -- VALUE_MAX recognizes the second value of a range constraint.
  8633.  
  8634.         SAVE_CURRENT : POSITIVE;
  8635.  
  8636.         begin
  8637.             SAVE_CURRENT := CURRENT;
  8638.             CURRENT := CURRENT + 1;
  8639.  
  8640.             while COLUMN_LIST_COPY (CURRENT) /= ' ' and
  8641.                   COLUMN_LIST_COPY (CURRENT) /= ';' and
  8642.                   COLUMN_LIST_COPY (CURRENT) /= '$' and
  8643.                   COLUMN_LIST_COPY (CURRENT) /= ',' and
  8644.                   COLUMN_LIST_COPY (CURRENT) /= '(' and
  8645.                   COLUMN_LIST_COPY (CURRENT) /= ')' and
  8646.                   COLUMN_LIST_COPY (CURRENT .. CURRENT + 1) /= ".." loop
  8647.                 CURRENT := CURRENT + 1;
  8648.             end loop;
  8649.  
  8650.                 -- store now in MAXVALUE the recognized value.
  8651.             if CURRENT - SAVE_CURRENT < RANGE_SIZE + 1 then
  8652.                     -- one to RANGE_SIZE characters long value.
  8653.                 MAXVALUE :=
  8654.                      COLUMN_LIST_COPY (SAVE_CURRENT .. CURRENT - 1)
  8655.                   &  (CURRENT - SAVE_CURRENT + 1 .. RANGE_SIZE => ' ');
  8656.             else
  8657.                     -- more than RANGE_SIZE characters long image
  8658.                 MAXVALUE := COLUMN_LIST_COPY
  8659.                         (SAVE_CURRENT .. SAVE_CURRENT + RANGE_SIZE - 1);
  8660.             end if;
  8661.  
  8662.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8663.                 CURRENT := CURRENT + 1;
  8664.             end loop;
  8665.         end VALUE_MAX;
  8666.  
  8667.                          -----------------
  8668.                          -- TWO_PERIODS --
  8669.                          -----------------
  8670.         procedure TWO_PERIODS is
  8671.             -- TWO_PERIODS recognizes the two periods between the two
  8672.             -- values of a range constraint.
  8673.  
  8674.         begin
  8675.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 1) = ".." then
  8676.                 CURRENT := CURRENT + 2;
  8677.                 while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8678.                     CURRENT := CURRENT + 1;
  8679.                 end loop;
  8680.  
  8681.             else
  8682.                 ERROR;
  8683.             end if;
  8684.         end TWO_PERIODS;
  8685.  
  8686.                          ----------------
  8687.                          -- CONSTRAINT --
  8688.                          ----------------
  8689.         procedure CONSTRAINT is
  8690.             -- CONSTRAINT recognizes a range constraint.
  8691.  
  8692.         begin
  8693.             if IS_RANGE then
  8694.                 GO_AHEAD;
  8695.                 VALUE_MIN;
  8696.                 TWO_PERIODS;
  8697.                 VALUE_MAX;
  8698.                         
  8699.                         -- store now in the ADARANGE reserved table
  8700.                         -- the above defined range constraint.
  8701.                 ADA_TABLES.PUT_RANGE (COLUMN_NAME, MINVALUE, MAXVALUE);
  8702.             end if;
  8703.         end CONSTRAINT;
  8704.  
  8705.  
  8706.                  --------------------------------
  8707.                  -- INDEX_CONSTRAINT_BEGINNING --
  8708.                  --------------------------------
  8709.         procedure INDEX_CONSTRAINT_BEGINNING is
  8710.             -- INDEX_CONSTRAINT_BEGINNING recognizes the beginning of a
  8711.             -- size specification for a character string, i.e. the
  8712.             -- following items :
  8713.             --          (1..
  8714.             -- which are normally followed by a positive number and a
  8715.             -- right parenthesis, such as :
  8716.             --          (1..n)
  8717.  
  8718.         begin
  8719.             CURRENT := CURRENT + 1;
  8720.  
  8721.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8722.                 CURRENT := CURRENT + 1;
  8723.             end loop;
  8724.  
  8725.             if COLUMN_LIST_COPY (CURRENT) = '1' then
  8726.                 CURRENT := CURRENT + 1;
  8727.             else
  8728.                 ERROR;
  8729.             end if;
  8730.  
  8731.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8732.                 CURRENT := CURRENT + 1;
  8733.             end loop;
  8734.  
  8735.             if COLUMN_LIST_COPY (CURRENT .. CURRENT + 1) = ".." then
  8736.                 CURRENT := CURRENT + 2;
  8737.             else
  8738.                 ERROR;
  8739.             end if;
  8740.  
  8741.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8742.                 CURRENT := CURRENT + 1;
  8743.             end loop;
  8744.         end INDEX_CONSTRAINT_BEGINNING;
  8745.  
  8746.                       -----------------------
  8747.                       -- RIGHT_PARENTHESIS --
  8748.                       -----------------------
  8749.         procedure RIGHT_PARENTHESIS is
  8750.             -- recognize a right parenthesis
  8751.  
  8752.         begin
  8753.             if COLUMN_LIST_COPY (CURRENT) = ')' then
  8754.                 GO_AHEAD;
  8755.             else
  8756.                 ERROR;
  8757.             end if;
  8758.         end RIGHT_PARENTHESIS;
  8759.  
  8760.  
  8761.                          ----------------
  8762.                          -- ENUM_IMAGE --
  8763.                          ----------------
  8764.         procedure ENUM_IMAGE is
  8765.             -- ENUM_IMAGE recognizes an item of an enumeration list;
  8766.             -- in fact, it accepts any word composed of letters, digits
  8767.             -- and underscores, without taking care of their order (for
  8768.             -- instance, a word beginning with an underscore or a digit
  8769.             -- will be accepted, another containing two consecutive
  8770.             -- underscores will be accepted too).
  8771.  
  8772.         SAVE_CURRENT : POSITIVE;
  8773.  
  8774.         begin
  8775.             SAVE_CURRENT := CURRENT;
  8776.  
  8777.             while COLUMN_LIST_COPY (CURRENT) = '_' or
  8778.                   (COLUMN_LIST_COPY (CURRENT) >= '0' and
  8779.                    COLUMN_LIST_COPY (CURRENT) <= '9') or
  8780.                   (COLUMN_LIST_COPY (CURRENT) >= 'A' and
  8781.                    COLUMN_LIST_COPY (CURRENT) <= 'Z') loop
  8782.                 CURRENT := CURRENT + 1;
  8783.             end loop;
  8784.  
  8785.                 -- store now in ENUM_LITERAL the recognized image.
  8786.             if CURRENT - SAVE_CURRENT < IMAGE_SZ + 1 then
  8787.                     -- one to IMAGE_SZ characters long image
  8788.                 ENUM_LITERAL :=
  8789.                      COLUMN_LIST_COPY (SAVE_CURRENT .. CURRENT - 1)
  8790.                   &  (CURRENT - SAVE_CURRENT + 1 .. IMAGE_SZ => ' ');
  8791.             else
  8792.                     -- more than IMAGE_SZ characters long image
  8793.                 ENUM_LITERAL := COLUMN_LIST_COPY
  8794.                         (SAVE_CURRENT .. SAVE_CURRENT + IMAGE_SZ - 1);
  8795.             end if;
  8796.  
  8797.                 -- store now in the ADAENUM reserved table the item
  8798.                 -- just above recognized.
  8799.             ADA_TABLES.PUT_ENUM (COLUMN_NAME, ENUM_VALUE, ENUM_LITERAL);
  8800.  
  8801.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8802.                 CURRENT := CURRENT + 1;
  8803.             end loop;
  8804.         end ENUM_IMAGE;
  8805.  
  8806.                         ------------------
  8807.                         -- SCALAR_DESCR --
  8808.                         ------------------
  8809.         procedure SCALAR_DESCR is
  8810.             -- SCALAR_DESCR recognizes a scalar type, i.e. :
  8811.             --  STRING (1 .. 10) by default;
  8812.             --  STRING (1 .. n);
  8813.             --  FLOAT;
  8814.             --  INTEGER (n bytes wide, n being specified, or being
  8815.             --          chosen to 4 by default);
  8816.             --  an enumeration type, defined by items enclosed in
  8817.             --          parentheses.
  8818.             -- Each of these types can have a range constraint, which
  8819.             -- is recognized by the above defined CONSTRAINT procedure,
  8820.             -- except the STRING type.
  8821.  
  8822.  
  8823.                        --------------------
  8824.                        -- NATURAL_NUMBER --
  8825.                        --------------------
  8826.             procedure NATURAL_NUMBER is
  8827.                 -- recognize a natural number
  8828.  
  8829.             begin
  8830.  
  8831.                 while COLUMN_LIST_COPY (CURRENT) >= '0' and
  8832.                       COLUMN_LIST_COPY (CURRENT) <= '9' loop
  8833.                     CURRENT := CURRENT + 1;
  8834.                 end loop;
  8835.  
  8836.                 while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8837.                     CURRENT := CURRENT + 1;
  8838.                 end loop;
  8839.             end NATURAL_NUMBER;
  8840.  
  8841.         begin
  8842.             if IS_STRING then
  8843.                         -- the type is a STRING type
  8844.  
  8845.                 GO_AHEAD;
  8846.  
  8847.                 if COLUMN_LIST_COPY (CURRENT) = '(' then
  8848.                         -- this string type has an index constraint
  8849.  
  8850.                     INDEX_CONSTRAINT_BEGINNING;
  8851.                     NATURAL_NUMBER;
  8852.                     RIGHT_PARENTHESIS;
  8853.  
  8854.                 end if;
  8855.  
  8856.             elsif IS_FLOAT then
  8857.                         -- the type is a FLOAT type
  8858.  
  8859.                 GO_AHEAD;
  8860.  
  8861.                 CONSTRAINT;
  8862.  
  8863.             elsif IS_INTEGER then
  8864.                         -- the type is an INTEGER type
  8865.  
  8866.                 GO_AHEAD;
  8867. --------------------------------------------------------------------------
  8868. --
  8869. --      Following comments must be executed if the byte length of
  8870. -- INTEGER type can be chosen; otherwise, 32 bits is chosen for
  8871. -- default length.
  8872. --
  8873. --              if IS_NATURAL_NUMBER then
  8874. --                      -- this INTEGER type has a size specification
  8875. --
  8876. --                  NATURAL_NUMBER;
  8877. --
  8878. --              end if;
  8879. --
  8880. --------------------------------------------------------------------------
  8881.  
  8882.                 CONSTRAINT;
  8883.  
  8884.             elsif COLUMN_LIST_COPY (CURRENT) = '(' then
  8885.                         -- the type is an enumeration type
  8886.  
  8887.                 CURRENT := CURRENT + 1;
  8888.  
  8889.                 while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8890.                     CURRENT := CURRENT + 1;
  8891.                 end loop;
  8892.  
  8893.                 ENUM_VALUE := 0;
  8894.                 ENUM_IMAGE;
  8895.                         -- recognize the first item
  8896.  
  8897.                 while COLUMN_LIST_COPY (CURRENT) = ',' loop
  8898.                         -- than recognize each of the following items
  8899.  
  8900.                     CURRENT := CURRENT + 1;
  8901.  
  8902.                     while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8903.                         CURRENT := CURRENT + 1;
  8904.                     end loop;
  8905.  
  8906.                     ENUM_VALUE := ENUM_VALUE + 1;
  8907.                     ENUM_IMAGE;
  8908.                 end loop;
  8909.  
  8910.                 if COLUMN_LIST_COPY (CURRENT) = ')' then
  8911.                         -- check that the enumeration list ends with a
  8912.                         -- right parenthesis.
  8913.  
  8914.                     CURRENT := CURRENT + 1;
  8915.  
  8916.                     while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8917.                         CURRENT := CURRENT + 1;
  8918.                     end loop;
  8919.                 else
  8920.                         -- the enumeration list does not end with a
  8921.                         -- right parenthesis.
  8922.  
  8923.                     ERROR;
  8924.                 end if;
  8925.  
  8926.                 CONSTRAINT;
  8927.             end if;
  8928.  
  8929.         end SCALAR_DESCR;
  8930.  
  8931.                             ----------
  8932.                             -- NAME --
  8933.                             ----------
  8934.         procedure NAME is
  8935.                 -- NAME recognizes a column name (either an Ada or a
  8936.                 -- DAMES column, since Ada record columns are composed
  8937.                 -- of several DAMES columns, one for each component).
  8938.                 -- Such an identifier must begin with a letter, which
  8939.                 -- is followed by other letters, digits, periods,
  8940.                 -- equal signs, or underscores.
  8941.  
  8942.             SAVE_CURRENT : POSITIVE;
  8943.  
  8944.         begin
  8945.             if COLUMN_LIST_COPY (CURRENT) >= 'A' and
  8946.                COLUMN_LIST_COPY (CURRENT) <= 'Z' then
  8947.                 
  8948.                 SAVE_CURRENT := CURRENT;
  8949.                 CURRENT := CURRENT + 1;
  8950.  
  8951.                 while (COLUMN_LIST_COPY (CURRENT) >= 'A' and
  8952.                        COLUMN_LIST_COPY (CURRENT) <= 'Z') or
  8953.                       (COLUMN_LIST_COPY (CURRENT) >= '0' and
  8954.                        COLUMN_LIST_COPY (CURRENT) <= '9') or
  8955.                       COLUMN_LIST_COPY (CURRENT) = '_' or
  8956.                       COLUMN_LIST_COPY (CURRENT) = '.' or
  8957.                       COLUMN_LIST_COPY (CURRENT) = '=' loop
  8958.                     CURRENT := CURRENT + 1;
  8959.                 end loop;
  8960.  
  8961.                         -- store now in COLUMN_NAME the recognized name
  8962.                 if CURRENT - SAVE_CURRENT < 11 then
  8963.                         -- one to ten characters long name
  8964.                     COLUMN_NAME :=
  8965.                         COLUMN_LIST_COPY (SAVE_CURRENT .. CURRENT - 1)
  8966.                         &      (CURRENT - SAVE_CURRENT + 1 .. 12 => ' ');
  8967.                 else
  8968.                         -- more than ten characters long name
  8969.                     COLUMN_NAME := COLUMN_LIST_COPY
  8970.                         (SAVE_CURRENT .. SAVE_CURRENT + 9) & "  ";
  8971.                 end if;
  8972.  
  8973.                 while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  8974.                     CURRENT := CURRENT + 1;
  8975.                 end loop;
  8976.             else
  8977.                     -- the current token does not begin with a letter
  8978.  
  8979.                 ERROR;
  8980.             end if;
  8981.         end NAME;
  8982.  
  8983.  
  8984.                        ---------------------
  8985.                        -- IS_SCALAR_DESCR --
  8986.                        ---------------------
  8987.         function IS_SCALAR_DESCR return BOOLEAN is
  8988.                 -- IS_SCALAR_DESCR returns TRUE if the current token is
  8989.                 -- the beginning of a type specification, and returns
  8990.                 -- FALSE otherwise (if the sentence is syntactically
  8991.                 -- correct, it means the token is a column name).
  8992.         begin
  8993.             if COLUMN_LIST_COPY (CURRENT) = ',' or
  8994.                COLUMN_LIST_COPY (CURRENT) = ';' or
  8995.                COLUMN_LIST_COPY (CURRENT) = '$' or
  8996.                IS_STRING or
  8997.                IS_FLOAT or IS_INTEGER or COLUMN_LIST_COPY (CURRENT) = '(' then
  8998.                 return TRUE;
  8999.             else
  9000.                 return FALSE;
  9001.             end if;
  9002.         end IS_SCALAR_DESCR;
  9003.  
  9004.  
  9005.  
  9006.                         ------------------
  9007.                         -- COLUMN_DESCR --
  9008.                         ------------------
  9009.         procedure COLUMN_DESCR is
  9010.                 -- COLUMN_DESCR recognizes a column descriptor, which
  9011.                 -- is a column name followed by a scalar descriptor
  9012.                 -- or a record descriptor.
  9013.  
  9014.         begin
  9015.             NAME;
  9016.  
  9017.             if IS_SCALAR_DESCR then
  9018.                 SCALAR_DESCR;
  9019.             else
  9020.                 RECORD_NAME := COLUMN_NAME;
  9021.                         -- The variable COLUMN_NAME, which in fact is
  9022.                         -- the  name  of  a  record  column  has  been
  9023.                         -- previously recognized by the NAME procedure.
  9024.  
  9025.                 NAME;
  9026.                 SCALAR_DESCR;
  9027.  
  9028.                         -- since the current column is a record column
  9029.                         -- (i.e. several DAMES columns linked together),
  9030.                         -- it is to be recorded in the ADARANGE reserved
  9031.                         -- table for each of the component column.
  9032.                 ADA_TABLES.PUT_RECORD (RECORD_NAME, COLUMN_NAME);
  9033.  
  9034.                 while COLUMN_LIST_COPY (CURRENT) = ',' loop
  9035.                     CURRENT := CURRENT + 1;
  9036.  
  9037.                     while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  9038.                         CURRENT := CURRENT + 1;
  9039.                     end loop;
  9040.  
  9041.                     NAME;
  9042.                     SCALAR_DESCR;
  9043.                     ADA_TABLES.PUT_RECORD (RECORD_NAME, COLUMN_NAME);
  9044.                 end loop;
  9045.             end if;
  9046.         end COLUMN_DESCR;     begin
  9047.         COLUMN_LIST_COPY := COLUMN_LIST & "$       ";
  9048.         UPPER_CASE (COLUMN_LIST_COPY);
  9049.         CURRENT := 1;
  9050.  
  9051.         while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  9052.             CURRENT := CURRENT + 1;
  9053.         end loop;
  9054.  
  9055.         COLUMN_DESCR;
  9056.  
  9057.         while COLUMN_LIST_COPY (CURRENT) = ';' loop
  9058.             CURRENT := CURRENT + 1;
  9059.  
  9060.             while COLUMN_LIST_COPY (CURRENT) = ' ' loop
  9061.                 CURRENT := CURRENT + 1;
  9062.             end loop;
  9063.  
  9064.             COLUMN_DESCR;
  9065.         end loop;
  9066.         
  9067.         if COLUMN_LIST_COPY (CURRENT) /= '$' then
  9068.             ERROR;
  9069.         end if;
  9070.         
  9071.     end PARSE_SECOND_LEVEL;
  9072.  
  9073. end PARSE;
  9074. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9075. --damespec.txt
  9076. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9077. package DAMES is
  9078.  
  9079.     X_DAMES_ERROR : exception;
  9080.  
  9081.  
  9082.     procedure EXECUTE            (COMMAND : STRING);
  9083. --************************************************************************
  9084. --**                                                                    **
  9085. --**      UNIT NAME :                EXECUTE                            **
  9086. --**      ~~~~~~~~~~~                                                   **
  9087. --**                                                                    **
  9088. --** DESCRIPTION--------------------------------------------------------**
  9089. --**                                                                    **
  9090. --**  This procedure executes the DAMES command written in the COMMAND  **
  9091. --**  string (See the 'User Language manual' for the  syntax  of DAMES  **
  9092. --**  commands).                                                        **
  9093. --**  The database  processed  by  the  command  must first be open by  **
  9094. --**  using the following Ada instruction :                             **
  9095. --**  'DAMES.EXECUTE ("open DATABASE_NAME ;");'                         **
  9096. --**  where DATABASE_NAME is the name of the database to be processed,  **
  9097. --**  or  by  using  the  equivalent  Ada  instruction  :               **
  9098. --**  'DAMES.OPEN ("DATABASE_NAME");'                                   **
  9099. --**                                                                    **
  9100. --**                                                                    **
  9101. --** INPUT--------------------------------------------------------------**
  9102. --**                                                                    **
  9103. --**  COMMAND is a character string in which a command to be executed   **
  9104. --**  has previously been written; this character string  has  a  max   **
  9105. --**  size which depends on the generation of DAMES.                    **
  9106. --**                                                                    **
  9107. --** OUTPUT-------------------------------------------------------------**
  9108. --**                                                                    **
  9109. --** EXCEPTIONS---------------------------------------------------------**
  9110. --**                                                                    **
  9111. --**  X_DAMES_ERROR is raised if an error occurs during the parsing or  **
  9112. --**  execution of the COMMAND string.                                  **
  9113. --**                                                                    **
  9114. --************************************************************************
  9115.  
  9116.     procedure CLOSE;
  9117. --************************************************************************
  9118. --**                                                                    **
  9119. --**   UNIT NAME :               CLOSE                                  **
  9120. --**   ~~~~~~~~~~~                                                      **
  9121. --**                                                                    **
  9122. --** DESCRIPTION--------------------------------------------------------**
  9123. --**                                                                    **
  9124. --**  This procedure must be called after OPEN or EXECUTE have been used**
  9125. --**  one or several times in an Ada program.                           **
  9126. --**                                                                    **
  9127. --** INPUT--------------------------------------------------------------**
  9128. --**                                                                    **
  9129. --** OUTPUT-------------------------------------------------------------**
  9130. --**                                                                    **
  9131. --** EXCEPTIONS---------------------------------------------------------**
  9132. --**                                                                    **
  9133. --************************************************************************
  9134.  
  9135.     procedure OPEN  (DB_NAME : STRING);
  9136. --************************************************************************
  9137. --**                                                                    **
  9138. --**   UNIT NAME :               OPEN                                   **
  9139. --**   ~~~~~~~~~~~                                                      **
  9140. --**                                                                    **
  9141. --** DESCRIPTION--------------------------------------------------------**
  9142. --**                                                                    **
  9143. --**  This procedure must be used to open a database to be accessed via **
  9144. --**  the embedded interface.                                           **
  9145. --**                                                                    **
  9146. --** INPUT--------------------------------------------------------------**
  9147. --**                                                                    **
  9148. --**  DB_NAME is the name of the database to be open.                   **
  9149. --**                                                                    **
  9150. --** OUTPUT-------------------------------------------------------------**
  9151. --**                                                                    **
  9152. --** EXCEPTIONS---------------------------------------------------------**
  9153. --**                                                                    **
  9154. --**    X_DAMES_ERROR is raised if the named database cannot be opened  **
  9155. --**                                                                    **
  9156. --************************************************************************
  9157.  
  9158. end DAMES;             
  9159.  
  9160. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9161. --dames.txt
  9162. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9163. with CONSTANTS;
  9164.         -- CONSTANTS contains the declarations of some useful constants
  9165.  
  9166. with F77_CALLABLES;
  9167.         -- F77_CALLABLES is the gate to be used to access the underlying
  9168.         -- Fortran77 DAMES subroutines.
  9169.  
  9170. with SHARE;
  9171.         -- SHARE contains two variables shared between DAMES and LL_DAMES
  9172.         
  9173. with DAMES_STATUS;
  9174.         -- DAMES_STATUS contains a variable which keeps in memory the
  9175.         -- current status of the DAMES embedded interface.
  9176.  
  9177.  
  9178. package body DAMES is
  9179.  
  9180.  
  9181.     procedure EXECUTE (COMMAND : STRING) is
  9182. --************************************************************************
  9183. --**                                                                    **
  9184. --**      UNIT NAME :                EXECUTE                            **
  9185. --**      ~~~~~~~~~~~                                                   **
  9186. --**                                                                    **
  9187. --** DESCRIPTION--------------------------------------------------------**
  9188. --**                                                                    **
  9189. --**                                                                    **
  9190. --**  if not EMBEDDED_INTERFACE_IS_IN_USE then                          ** 
  9191. --**                                                                    **
  9192. --**        -- this is the first call to EXECUTE                        **
  9193. --**                                                                    **
  9194. --**    INITIALIZE_EMBEDDED_INTERFACE;                                  **
  9195. --**  end if;                                                           **
  9196. --**                                                                    **
  9197. --**  PARSE_AND_EXECUTE (COMMAND);                                      **
  9198. --**                                                                    **
  9199. --**  if ERROR then                                                     **
  9200. --**                                                                    **
  9201. --**        -- an error occured during parsing or execution of COMMAND  **
  9202. --**                                                                    **
  9203. --**      raise X_DAMES_ERROR;                                          **
  9204. --**  end if;                                                           **
  9205. --**                                                                    **
  9206. --**  if USER_LANGUAGE_COMMAND = OPEN then                              **
  9207. --**                                                                    **
  9208. --**        -- if COMMAND is an OPEN DATABASE command, then the status  **
  9209. --**        -- must be updated                                          **
  9210. --**                                                                    **
  9211. --**    A_DATABASE_IS_OPEN := TRUE;                                     **
  9212. --**  end if;                                                           **
  9213. --**                                                                    **
  9214. --** INPUT--------------------------------------------------------------**
  9215. --**                                                                    **
  9216. --**  COMMAND is a character string in which a command to be executed   **
  9217. --**  has previously been written; this character string  has  a  max   **
  9218. --**  size which depends on the generation of DAMES.                    **
  9219. --**                                                                    **
  9220. --** STATUS VARIABLES USED----------------------------------------------**
  9221. --**                                                                    **
  9222. --**    EMBEDDED_INTERFACE_IS_IN_USE                                    **
  9223. --**                                                                    **
  9224. --** OUTPUT-------------------------------------------------------------**
  9225. --**                                                                    **
  9226. --** STATUS VARIABLES UPDATED-------------------------------------------**
  9227. --**                                                                    **
  9228. --**    EMBEDDED_INTERFACE_IS_IN_USE                                    **
  9229. --**    A_DATABASE_IS_OPEN                                              **
  9230. --**                                                                    **
  9231. --** EXCEPTIONS---------------------------------------------------------**
  9232. --**                                                                    **
  9233. --**  X_DAMES_ERROR is raised if an error occurs during the parsing or  **
  9234. --**  execution of the COMMAND string.                                  **
  9235. --**                                                                    **
  9236. --************************************************************************         INPLEN, RTN : INTEGER;
  9237.         DB_NAME : STRING (1 .. CONSTANTS.NAME_LENGTH)
  9238.                                         := (others => ' ');
  9239.         function COMMAND_IS_OPEN return BOOLEAN is
  9240.  
  9241.                 -- COMMAND_IS_OPEN returns 'true' if the User Language sentence
  9242.                 -- contained in the COMMAND character string contains the OPEN
  9243.                 -- command, and returns 'false' otherwise
  9244.  
  9245.             CLAST    : INTEGER := COMMAND'LENGTH;
  9246.             COMMAND2 : STRING (1 .. CLAST);
  9247.             INDEX, SAVE_INDEX : INTEGER;
  9248.         begin
  9249.                 -- copy COMMAND into COMMAND2 to enable its standardization
  9250.             COMMAND2 := COMMAND;
  9251.             INDEX := 1;
  9252.  
  9253.                 -- skip all blanks
  9254.             for I in 1 .. CLAST loop
  9255.                 if COMMAND2 (INDEX) = ' ' then
  9256.                     COMMAND2 (INDEX .. CLAST) :=
  9257.                       COMMAND2 (INDEX + 1 .. CLAST) & " ";
  9258.                 else
  9259.                     INDEX := INDEX + 1;
  9260.                 end if;
  9261.             end loop;
  9262.  
  9263.                 -- replace all lower-case characters with their upper-case
  9264.                 -- equivalent
  9265.             for I in 1 .. CLAST loop
  9266.                 if COMMAND2 (I) >= 'a' then
  9267.                     COMMAND2 (I) :=
  9268.                       CHARACTER'VAL (CHARACTER'POS (COMMAND2 (I)) - 32);
  9269.                 end if;
  9270.             end loop;
  9271.  
  9272.             INDEX := 1;
  9273.  
  9274.             while COMMAND2 (INDEX .. CLAST) /= (INDEX .. CLAST => ' ') loop
  9275.                     -- the User Language sentence can be composed of several
  9276.                     -- atomic commands separed with semicolons; each of these
  9277.                     -- commands is to be compared to "OPEN" until  equality
  9278.                     -- is reached.
  9279.                     -- This loop is performed one time for each atomic command
  9280.  
  9281.                 if COMMAND2 (INDEX .. INDEX + 3) = "OPEN" then
  9282.                     INDEX := INDEX + 4;
  9283.                     SAVE_INDEX := INDEX;
  9284.                     while COMMAND2 (INDEX) /= ';' loop
  9285.                         INDEX := INDEX + 1;
  9286.                     end loop;
  9287.                     DB_NAME (1 .. INDEX - SAVE_INDEX)
  9288.                         := COMMAND2 (SAVE_INDEX .. INDEX - 1);
  9289.                     return TRUE;
  9290.                 else
  9291.                         -- look now for the next semicolon (except those
  9292.                         -- included in character string literals)
  9293.                     loop
  9294.                         while COMMAND2 (INDEX) /= '"' and
  9295.                               COMMAND2 (INDEX) /= ';' loop
  9296.                             INDEX := INDEX + 1;
  9297.                         end loop;
  9298.                         INDEX := INDEX + 1;
  9299.                         exit when COMMAND2 (INDEX - 1) = ';';
  9300.  
  9301.                         while COMMAND2 (INDEX) /= '"' loop
  9302.                             INDEX := INDEX + 1;
  9303.                         end loop;
  9304.  
  9305.                         INDEX := INDEX + 1;
  9306.                     end loop;
  9307.                 end if;
  9308.             end loop;
  9309.  
  9310.             return FALSE;
  9311.         end COMMAND_IS_OPEN;
  9312.     begin
  9313.         if not DAMES_STATUS.EMBEDDED_INTERFACE_IS_IN_USE then
  9314.             if not SHARE.A_DATABASE_IS_OPEN then
  9315.                 F77_CALLABLES.ADA_STARTDM;
  9316.             end if;
  9317.             F77_CALLABLES.ADA_LEXINT;
  9318.             DAMES_STATUS.EMBEDDED_INTERFACE_IS_IN_USE := TRUE;
  9319.         end if;
  9320.  
  9321.         INPLEN := COMMAND'LENGTH;
  9322.         RTN := 0;
  9323.         F77_CALLABLES.ADA_DAMSG (COMMAND, INPLEN, 10_000, RTN);
  9324.         if RTN < 0 then
  9325.             raise X_DAMES_ERROR;
  9326.         end if;
  9327.  
  9328.         if RTN = 0 then
  9329.             F77_CALLABLES.ADA_PARSLP (RTN);
  9330.             if RTN /= 0 then
  9331.                 raise X_DAMES_ERROR;
  9332.             end if;
  9333.         end if;
  9334.  
  9335.         if COMMAND_IS_OPEN then
  9336.             SHARE.A_DATABASE_IS_OPEN := TRUE;
  9337.             SHARE.OPEN_DATABASE_NAME := DB_NAME;
  9338.         end if;
  9339.     end EXECUTE;     procedure CLOSE is
  9340. --************************************************************************
  9341. --**                                                                    **
  9342. --**   UNIT NAME :               CLOSE                                  **
  9343. --**   ~~~~~~~~~~~                                                      **
  9344. --**                                                                    **
  9345. --** DESCRIPTION--------------------------------------------------------**
  9346. --**                                                                    **
  9347. --**    if EMBEDDED_INTERFACE_IS_IN_USE then                            **
  9348. --**        CLOSE_EMBEDDED_INTERFACE;                                   **
  9349. --**        EMBEDDED_INTERFACE_IS_IN_USE := FALSE;                      **
  9350. --**        A_DATABASE_IS_OPEN := FALSE;                                **
  9351. --**    end if;                                                         **
  9352. --**                                                                    **
  9353. --**                                                                    **
  9354. --** INPUT--------------------------------------------------------------**
  9355. --**                                                                    **
  9356. --** STATUS VARIABLES USED----------------------------------------------**
  9357. --**                                                                    **
  9358. --**    EMBEDDED_INTERFACE_IS_IN_USE                                    **
  9359. --**                                                                    **
  9360. --** OUTPUT-------------------------------------------------------------**
  9361. --**                                                                    **
  9362. --** STATUS VARIABLES UPDATED-------------------------------------------**
  9363. --**                                                                    **
  9364. --**    EMBEDDED_INTERFACE_IS_IN_USE                                    **
  9365. --**    A_DATABASE_IS_OPEN                                              **
  9366. --**                                                                    **
  9367. --** EXCEPTIONS---------------------------------------------------------**
  9368. --**                                                                    **
  9369. --************************************************************************
  9370.     begin
  9371.         if DAMES_STATUS.EMBEDDED_INTERFACE_IS_IN_USE then
  9372.             F77_CALLABLES.ADA_ENDDM;
  9373.             DAMES_STATUS.EMBEDDED_INTERFACE_IS_IN_USE := FALSE;
  9374.             SHARE.A_DATABASE_IS_OPEN := FALSE;
  9375.         end if;
  9376.     end CLOSE;
  9377.  
  9378.     procedure OPEN (DB_NAME : STRING) is
  9379. --************************************************************************
  9380. --**                                                                    **
  9381. --**   UNIT NAME :               OPEN                                   **
  9382. --**   ~~~~~~~~~~~                                                      **
  9383. --**                                                                    **
  9384. --** DESCRIPTION--------------------------------------------------------**
  9385. --**                                                                    **
  9386. --**    EXECUTE ("open " & DB_NAME & ";");                              **
  9387. --**                                                                    **
  9388. --** INPUT--------------------------------------------------------------**
  9389. --**                                                                    **
  9390. --**  DB_NAME is the name of the database to be open.                   **
  9391. --**                                                                    **
  9392. --** STATUS VARIABLES USED----------------------------------------------**
  9393. --**                                                                    **
  9394. --**    EMBEDDED_INTERFACE_IS_IN_USE                                    **
  9395. --**                                                                    **
  9396. --** OUTPUT-------------------------------------------------------------**
  9397. --**                                                                    **
  9398. --** STATUS VARIABLES UPDATED-------------------------------------------**
  9399. --**                                                                    **
  9400. --**    EMBEDDED_INTERFACE_IS_IN_USE                                    **
  9401. --**    A_DATABASE_IS_OPEN                                              **
  9402. --**                                                                    **
  9403. --** EXCEPTIONS---------------------------------------------------------**
  9404. --**                                                                    **
  9405. --**      X_DAMES_ERROR  is  raised  if  the given database cannot  be  **
  9406. --**  opened, or if it does not exist.                                  **
  9407. --**                                                                    **
  9408. --************************************************************************
  9409.     begin
  9410.         EXECUTE ("OPEN " & DB_NAME & ";");
  9411.     end OPEN;
  9412.  
  9413.  
  9414. end DAMES;
  9415. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9416. --both.txt
  9417. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9418. with TEXT_IO;
  9419. use TEXT_IO;
  9420.  
  9421. package BOTH_VARIABLES is
  9422.  
  9423.     type INTERFACE_PROCEDURE_NAME is
  9424.      (DAMES_OPEN,           DAMES_EXECUTE,        DAMES_CLOSE,
  9425.       LL_D_OPEN,            LL_D_DEFINE_TABLE,    LL_D_LOCK,
  9426.       LL_D_GET_INFORMATION, LL_D_UNLOCK,          LL_D_CLOSE,
  9427.       LL_D_E_MATCH,         LL_D_F_MATCH,         LL_D_I_MATCH,
  9428.       LL_D_R_MATCH,         LL_D_S_MATCH,         LL_D_E_OR_MATCH,
  9429.       LL_D_F_OR_MATCH,      LL_D_I_OR_MATCH,      LL_D_R_OR_MATCH,
  9430.       LL_D_S_OR_MATCH,      LL_D_E_AND_MATCH,     LL_D_F_AND_MATCH,
  9431.       LL_D_I_AND_MATCH,     LL_D_R_AND_MATCH,     LL_D_S_AND_MATCH,
  9432.       LL_D_FIND,            LL_D_FIND_NEXT,       LL_D_FIND_PREVIOUS,
  9433.       LL_D_NEXT,            LL_D_PREVIOUS,        LL_D_E_GET_COLUMN,
  9434.       LL_D_F_GET_COLUMN,    LL_D_I_GET_COLUMN,    LL_D_R_GET_COLUMN,
  9435.       LL_D_S_GET_COLUMN,    LL_D_E_GET_ROW,       LL_D_F_GET_ROW,
  9436.       LL_D_I_GET_ROW,       LL_D_R_GET_ROW,       LL_D_S_GET_ROW,
  9437.       LL_D_E_BUILD_COLUMN,  LL_D_F_BUILD_COLUMN,  LL_D_I_BUILD_COLUMN,
  9438.       LL_D_R_BUILD_COLUMN,  LL_D_S_BUILD_COLUMN,  LL_D_E_BUILD_ROW,
  9439.       LL_D_F_BUILD_ROW,     LL_D_I_BUILD_ROW,     LL_D_R_BUILD_ROW,
  9440.       LL_D_S_BUILD_ROW,     LL_D_UPDATE,          LL_D_INSERT,
  9441.       LL_D_DELETE);
  9442.  
  9443.  
  9444.     type ACCESS_PROCEDURE_NAME is
  9445.      (ADA_ADDATR,  ADA_CLOSDB,  ADA_CLOSER,  ADA_CLRELS,  ADA_DADD,
  9446.       ADA_DAMSG,   ADA_DELETT,  ADA_DFIND,   ADA_DGINFO,  ADA_DLOCK,
  9447.       ADA_DOPENDB, ADA_DPREV,   ADA_DUNLK,   ADA_ENDDM,   ADA_FACSS,
  9448.       ADA_GETA,    ADA_GETT,    ADA_INSRTT,  ADA_IRELC,   ADA_LEXINT,
  9449.       ADA_NUMTUP,  ADA_OPENR,   ADA_PARSLP,  ADA_PUTA,    ADA_RELLK,
  9450.       ADA_REPLAT,  ADA_SETGET,  ADA_SETLK,   ADA_SRCHA,   ADA_STARTDM,
  9451.       ADA_TRELC,   ADA_MSGTTY);
  9452.  
  9453.  
  9454.     type PARAMETER_TYPE is (IN_PARAMETERS, OUT_PARAMETERS, TABLE_DESCRIPTORS);
  9455.  
  9456.     type TEST_BED_FUNCTION is (CREATE, DELETE, EXECUTE, MODIFY);
  9457.  
  9458.     subtype INTERFACE_NUMBER is NATURAL
  9459.                   range 0 .. INTERFACE_PROCEDURE_NAME'POS
  9460.                            (INTERFACE_PROCEDURE_NAME'LAST);
  9461.  
  9462.     subtype TEST_CASE_NUMBER is NATURAL range 1 .. 80;
  9463.     subtype ACC_LIST_NUMBER  is NATURAL range 0 .. 10;
  9464.  
  9465.     subtype ACCESS_NUMBER is NATURAL
  9466.                    range 0 .. ACCESS_PROCEDURE_NAME'POS
  9467.                         (ACCESS_PROCEDURE_NAME'LAST);
  9468.  
  9469.     type ACCESS_LIST is array (INTERFACE_NUMBER, ACC_LIST_NUMBER) of NATURAL;
  9470.  
  9471.     type IN_PARAMETER_IS_OPEN_TYPE is array (INTERFACE_NUMBER) of BOOLEAN;
  9472.  
  9473. --***************************************************************************--
  9474. --                               variables                                   --
  9475. --***************************************************************************--
  9476.  
  9477.  
  9478.     ACCESS_NB            : ACCESS_NUMBER := 0;
  9479.     ACC_LI_NB            : ACC_LIST_NUMBER := 0;
  9480.     ACCESS_PR_NAME       : ACCESS_PROCEDURE_NAME;
  9481.     AUTOMATIC_VERSION    : BOOLEAN := FALSE;
  9482.     INTERFACE_NB         : INTERFACE_NUMBER := 0;
  9483.     INTERFACE_PR_NAME    : INTERFACE_PROCEDURE_NAME;
  9484.     IN_PARAMETER_IS_OPEN : IN_PARAMETER_IS_OPEN_TYPE :=
  9485.                (2 | 7 | 8                    => FALSE,
  9486.                 0 | 1                       => TRUE,
  9487.                 3 .. 6                     => TRUE,
  9488.                 9 .. INTERFACE_NUMBER'LAST => TRUE);
  9489.     LOG_FILE             : FILE_TYPE;
  9490.     PARAMETER            : PARAMETER_TYPE;
  9491.     TEST_CASE_NB         : TEST_CASE_NUMBER := 1;
  9492.     T_B_FUNCTION         : TEST_BED_FUNCTION;
  9493.     ACC_LIST : ACCESS_LIST :=
  9494.            (00 => (05, 22, others => 99),
  9495.         01 => (05, 22, others => 99),
  9496.         02 => (others => 99),
  9497.         03 => (10, others => 99),
  9498.         04 => (18, 30, 00, 09, 21, 23, 17, others => 99),
  9499.         05 => (09, 21, 26, 08, 14, 16, 15, 28, others => 99),
  9500.         06 => (others => 99),
  9501.         07 => (others => 99),
  9502.         08 => (others => 99),
  9503.         09 => (others => 99),
  9504.         10 => (others => 99),
  9505.         11 => (others => 99),
  9506.         12 => (others => 99),
  9507.         13 => (others => 99),
  9508.         14 => (others => 99),
  9509.         15 => (others => 99),
  9510.         16 => (others => 99),
  9511.         17 => (others => 99),
  9512.         18 => (others => 99),
  9513.         19 => (others => 99),
  9514.         20 => (others => 99),
  9515.         21 => (others => 99),
  9516.         22 => (others => 99),
  9517.         23 => (others => 99),
  9518.         24 => (26, others => 99),
  9519.         25 => (16, 15, others => 99),
  9520.         26 => (15, 11, others => 99),
  9521.         27 => (16, others => 99),
  9522.         28 => (11, others => 99),
  9523.         29 => (15, others => 99),
  9524.         30 => (15, others => 99),
  9525.         31 => (15, others => 99),
  9526.         32 => (15, others => 99),
  9527.         33 => (15, others => 99),
  9528.         34 => (15, others => 99),
  9529.         35 => (15, others => 99),
  9530.         36 => (15, others => 99),
  9531.         37 => (15, others => 99),
  9532.         38 => (15, others => 99),
  9533.         39 => (23, others => 99),
  9534.         40 => (23, others => 99),
  9535.         41 => (23, others => 99),
  9536.         42 => (23, others => 99),
  9537.         43 => (23, others => 99),
  9538.         44 => (23, others => 99),
  9539.         45 => (23, others => 99),
  9540.         46 => (23, others => 99),
  9541.         47 => (23, others => 99),
  9542.         48 => (23, others => 99),
  9543.         49 => (06, 25, 14, 15, 07, 04, others => 99),
  9544.         50 => (17, 14, 15, 07, 04, others => 99),
  9545.         51 => (06, 20, others => 99));
  9546.  
  9547. end BOTH_VARIABLES;
  9548. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9549. --instan.txt
  9550. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9551. with TEXT_IO;
  9552. use TEXT_IO;
  9553. with LL_DAMES;
  9554. pragma ELABORATE (LL_DAMES);
  9555.  
  9556. package INSTANTIATED is
  9557.  
  9558.     subtype STR_10 is STRING (1 .. 10);
  9559.  
  9560.     type ENUM is (FIRST, SECOND, THIRD);
  9561.  
  9562.     type RECD is
  9563.     record
  9564.         INT : INTEGER := 0;
  9565.         FLO : FLOAT := 1.0;
  9566.         STR : STR_10 := "string....";
  9567.         ENU : ENUM := FIRST;
  9568.     end record;
  9569.  
  9570.  
  9571.     procedure I_MATCH is new LL_DAMES.MATCH (INTEGER);
  9572.     procedure F_MATCH is new LL_DAMES.MATCH (FLOAT);
  9573.     procedure S_MATCH is new LL_DAMES.MATCH (STR_10);
  9574.     procedure E_MATCH is new LL_DAMES.MATCH (ENUM);
  9575.     procedure R_MATCH is new LL_DAMES.MATCH (RECD);
  9576.  
  9577.  
  9578.     procedure I_OR_MATCH is new LL_DAMES.OR_MATCH (INTEGER);
  9579.     procedure F_OR_MATCH is new LL_DAMES.OR_MATCH (FLOAT);
  9580.     procedure S_OR_MATCH is new LL_DAMES.OR_MATCH (STR_10);
  9581.     procedure E_OR_MATCH is new LL_DAMES.OR_MATCH (ENUM);
  9582.     procedure R_OR_MATCH is new LL_DAMES.OR_MATCH (RECD);
  9583.  
  9584.  
  9585.     procedure I_AND_MATCH is new LL_DAMES.AND_MATCH (INTEGER);
  9586.     procedure F_AND_MATCH is new LL_DAMES.AND_MATCH (FLOAT);
  9587.     procedure S_AND_MATCH is new LL_DAMES.AND_MATCH (STR_10);
  9588.     procedure E_AND_MATCH is new LL_DAMES.AND_MATCH (ENUM);
  9589.     procedure R_AND_MATCH is new LL_DAMES.AND_MATCH (RECD);
  9590.  
  9591.  
  9592.     procedure I_GET_COLUMN is new LL_DAMES.GET_COLUMN (INTEGER);
  9593.     procedure F_GET_COLUMN is new LL_DAMES.GET_COLUMN (FLOAT);
  9594.     procedure S_GET_COLUMN is new LL_DAMES.GET_COLUMN (STR_10);
  9595.     procedure E_GET_COLUMN is new LL_DAMES.GET_COLUMN (ENUM);
  9596.     procedure R_GET_COLUMN is new LL_DAMES.GET_COLUMN (RECD);
  9597.  
  9598.  
  9599.     procedure I_GET_ROW is new LL_DAMES.GET_ROW (INTEGER);
  9600.     procedure F_GET_ROW is new LL_DAMES.GET_ROW (FLOAT);
  9601.     procedure S_GET_ROW is new LL_DAMES.GET_ROW (STR_10);
  9602.     procedure E_GET_ROW is new LL_DAMES.GET_ROW (ENUM);
  9603.     procedure R_GET_ROW is new LL_DAMES.GET_ROW (RECD);
  9604.  
  9605.  
  9606.     procedure I_BUILD_COLUMN is new LL_DAMES.BUILD_COLUMN (INTEGER);
  9607.     procedure F_BUILD_COLUMN is new LL_DAMES.BUILD_COLUMN (FLOAT);
  9608.     procedure S_BUILD_COLUMN is new LL_DAMES.BUILD_COLUMN (STR_10);
  9609.     procedure E_BUILD_COLUMN is new LL_DAMES.BUILD_COLUMN (ENUM);
  9610.     procedure R_BUILD_COLUMN is new LL_DAMES.BUILD_COLUMN (RECD);
  9611.  
  9612.     procedure I_BUILD_ROW is new LL_DAMES.BUILD_ROW (INTEGER);
  9613.     procedure F_BUILD_ROW is new LL_DAMES.BUILD_ROW (FLOAT);
  9614.     procedure S_BUILD_ROW is new LL_DAMES.BUILD_ROW (STR_10);
  9615.     procedure E_BUILD_ROW is new LL_DAMES.BUILD_ROW (ENUM);
  9616.     procedure R_BUILD_ROW is new LL_DAMES.BUILD_ROW (RECD);
  9617.  
  9618.     package I is new INTEGER_IO (INTEGER);
  9619.     package F is new FLOAT_IO (FLOAT);
  9620.  
  9621. end INSTANTIATED;
  9622. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9623. --dispec.txt
  9624. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9625. with TEXT_IO;
  9626. use TEXT_IO;
  9627.  
  9628. package DISPLAY is
  9629.  
  9630. --***************************************************************************--
  9631. --                           types                                           --
  9632. --***************************************************************************--
  9633.  
  9634.     type CHOICE_SWITCH is (R_O_W, C_O_L);
  9635.     type DISPLAY_SWITCH_TYPE is (READ, MODIFY, LIST);
  9636.  
  9637.     subtype COLUMN_TYPE is INTEGER range 0 .. 79;
  9638.     subtype ROW_TYPE    is INTEGER range 0 .. 23;
  9639.  
  9640.  
  9641. --***************************************************************************--
  9642. --                              variables                                    --
  9643. --***************************************************************************--
  9644.  
  9645.     A              : CHARACTER;
  9646.     B              : STRING (1 .. 2);
  9647.     COLUMN         : COLUMN_TYPE;
  9648.     DISPLAY_SWITCH : DISPLAY_SWITCH_TYPE := MODIFY;
  9649.     LAST           : NATURAL;
  9650.     ROW            : ROW_TYPE;
  9651. --***************************************************************************--
  9652. --                           procedures                                      --
  9653. --***************************************************************************--
  9654.  
  9655.     procedure NEWPAGE;
  9656.  
  9657.     procedure DISP (LINE : POSITIVE_COUNT; TEXT : STRING);
  9658.  
  9659.     procedure DISPL (COLUMN : COLUMN_TYPE; ROW : ROW_TYPE; TEXT : STRING);
  9660.  
  9661.     procedure STOP;
  9662.  
  9663.     procedure PRINT (S : STRING);
  9664.  
  9665.     procedure CHOICE (ROWCOL_SWITCH : CHOICE_SWITCH;
  9666.               LAST_ROWCOL   : COLUMN_TYPE;
  9667.               ROW           : in out ROW_TYPE;
  9668.               COLUMN        : in out COLUMN_TYPE);
  9669.  
  9670.     procedure SCREEN_POS (COLUMN : COLUMN_TYPE; ROW : ROW_TYPE);
  9671. -- move the cursor to the requested location
  9672.  
  9673.     function MODIFY return BOOLEAN;
  9674. -- ask the user if he wants to modify the currently displayed screen and return
  9675. -- TRUE if he wants and FALSE if he does not.
  9676.  
  9677.     procedure INITIALIZE_STATUS;
  9678. -- initialize the TABLE_DESCRIPTOR package to meaningful values
  9679.  
  9680.     procedure UPDATE_STATUS;
  9681. -- display and update the TABLE_DESCRIPTOR package content.
  9682.  
  9683. end DISPLAY;
  9684. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9685. --display.txt
  9686. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9687. with TTY_IO;
  9688. with CONSTANTS;
  9689. use CONSTANTS;
  9690. with SHARE;
  9691. use SHARE;
  9692. with DAMES_STATUS;
  9693. use DAMES_STATUS;
  9694. with TABLE_DESCRIPTOR;
  9695. use TABLE_DESCRIPTOR;
  9696. with LL_DAMES;
  9697. use LL_DAMES;
  9698. with BOTH_VARIABLES;
  9699. use BOTH_VARIABLES;
  9700.  
  9701. package body DISPLAY is
  9702.  
  9703. -------------------------------------------------------------------------------
  9704. --                        procedure NEWPAGE                                  --
  9705. -------------------------------------------------------------------------------
  9706.     procedure NEWPAGE is
  9707.  
  9708.     begin
  9709.     case DISPLAY_SWITCH is
  9710.         when MODIFY | READ => 
  9711.         SET_OUTPUT (STANDARD_OUTPUT);
  9712.         NEW_PAGE;
  9713.         PUT (TEST_BED_FUNCTION'IMAGE (T_B_FUNCTION) &
  9714.              " interface procedure " &
  9715.              INTERFACE_PROCEDURE_NAME'IMAGE (INTERFACE_PR_NAME) & " ");
  9716.         case PARAMETER is
  9717.             when IN_PARAMETERS | TABLE_DESCRIPTORS => 
  9718.             PUT (PARAMETER_TYPE'IMAGE (PARAMETER));
  9719.             when OUT_PARAMETERS => 
  9720.             NEW_LINE;
  9721.             PUT ("access procedure " &
  9722.                  ACCESS_PROCEDURE_NAME'IMAGE (ACCESS_PR_NAME) &
  9723.                  " " & PARAMETER_TYPE'IMAGE (PARAMETER));
  9724.         end case;
  9725.         when LIST => 
  9726.         SET_OUTPUT (LOG_FILE);
  9727.     end case;
  9728.     if PARAMETER /= OUT_PARAMETERS then
  9729.         NEW_LINE (3);
  9730.     end if;
  9731.     end NEWPAGE;
  9732.  
  9733. -------------------------------------------------------------------------------
  9734. --                        procedure DISP                                     --
  9735. -------------------------------------------------------------------------------
  9736.     procedure DISP (LINE : POSITIVE_COUNT; TEXT : STRING) is
  9737.     begin
  9738.     SET_LINE (LINE);
  9739.     PUT (TEXT);
  9740.     end DISP;
  9741.  
  9742. -------------------------------------------------------------------------------
  9743. --                        procedure DISPL                                    --
  9744. -------------------------------------------------------------------------------
  9745.     procedure DISPL (COLUMN : COLUMN_TYPE; ROW : ROW_TYPE; TEXT : STRING) is
  9746.     begin
  9747.     TTY_IO.PUT (ASCII.DLE & CHARACTER'VAL (COLUMN) & CHARACTER'VAL (ROW));
  9748.     PUT (TEXT);
  9749.     end DISPL;
  9750.  
  9751. -------------------------------------------------------------------------------
  9752. --                        procedure STOP                                     --
  9753. -------------------------------------------------------------------------------
  9754.     procedure STOP is
  9755.     begin
  9756.     if not AUTOMATIC_VERSION then
  9757.         DISPL (0, 22, "Press ""NEW LINE"" to continue                    ");
  9758.         DISPL (0, 23, "                                                  ");
  9759.         SCREEN_POS (0, 22);
  9760.         GET_LINE (B, LAST);
  9761.     end if;
  9762.     end STOP;
  9763.  
  9764. -------------------------------------------------------------------------------
  9765. --                           procedure PRINT                                 --
  9766. -------------------------------------------------------------------------------
  9767.     procedure PRINT (S : STRING) is
  9768.  
  9769.     begin
  9770.     PARAMETER := OUT_PARAMETERS;
  9771.     if not AUTOMATIC_VERSION then
  9772.         SET_OUTPUT (STANDARD_OUTPUT);
  9773.         NEW_PAGE;
  9774.         PUT (TEST_BED_FUNCTION'IMAGE (T_B_FUNCTION) &
  9775.          " interface procedure " &
  9776.          INTERFACE_PROCEDURE_NAME'IMAGE (INTERFACE_PR_NAME) & " " &
  9777.          PARAMETER_TYPE'IMAGE (PARAMETER));
  9778.         DISPL (0, 4, S);
  9779.         STOP;
  9780.     end if;
  9781.     SET_OUTPUT (LOG_FILE);
  9782.     NEW_LINE (3);
  9783.     PUT ("--------------- INTERFACE PROCEDURE OUT_PARAMETERS -----------");
  9784.     NEW_LINE (2);
  9785.     PUT (S);
  9786.     SET_OUTPUT (STANDARD_OUTPUT);
  9787.     PARAMETER := IN_PARAMETERS;
  9788.     end PRINT;
  9789. -------------------------------------------------------------------------------
  9790. --                        procedure CHOICE                                   --
  9791. -------------------------------------------------------------------------------
  9792.     procedure CHOICE (ROWCOL_SWITCH : CHOICE_SWITCH;
  9793.               LAST_ROWCOL   : COLUMN_TYPE;
  9794.               ROW           : in out ROW_TYPE;
  9795.               COLUMN        : in out COLUMN_TYPE) is
  9796.  
  9797.     begin
  9798.     TTY_IO.ECHO_OFF;
  9799.     loop
  9800.         TTY_IO.PUT (ASCII.DLE & CHARACTER'VAL (COLUMN) &
  9801.             CHARACTER'VAL (ROW));
  9802.         TTY_IO.GET (A);
  9803.         case A is
  9804.         when ASCII.CR =>  exit;
  9805.         when ASCII.LF => 
  9806.             if ROWCOL_SWITCH = R_O_W then
  9807.             ROW := ROW + 1;
  9808.             exit when ROW = LAST_ROWCOL + 1;
  9809.             else
  9810.             COLUMN := COLUMN + 1;
  9811.             exit when COLUMN = LAST_ROWCOL + 1;
  9812.             end if;
  9813.         when others =>  null;
  9814.         end case;
  9815.     end loop;
  9816.     TTY_IO.ECHO_ON;
  9817.     end CHOICE;
  9818.  
  9819. -------------------------------------------------------------------------------
  9820. --                        procedure SCREEN_POS                               --
  9821. -------------------------------------------------------------------------------
  9822.     procedure SCREEN_POS (COLUMN : COLUMN_TYPE; ROW : ROW_TYPE) is
  9823.     begin
  9824.     if DISPLAY_SWITCH = LIST then
  9825.         SET_COL (POSITIVE_COUNT (COLUMN + 1));
  9826.     else
  9827.         TTY_IO.PUT (ASCII.DLE & CHARACTER'VAL (COLUMN) &
  9828.             CHARACTER'VAL (ROW));
  9829.     end if;
  9830.     end SCREEN_POS;
  9831.  
  9832. -------------------------------------------------------------------------------
  9833. --                        function  MODIFY                                   --
  9834. -------------------------------------------------------------------------------
  9835.     function MODIFY return BOOLEAN is
  9836.     ANSWER : CHARACTER;
  9837.     begin
  9838.     case DISPLAY_SWITCH is
  9839.         when MODIFY => 
  9840.         SCREEN_POS (0, 23);
  9841.         PUT ("Do you want to modify these values ? (y/n) ");
  9842.         GET (ANSWER);
  9843.  
  9844.         if ANSWER = 'y' or ANSWER = 'Y' then
  9845.             return TRUE;
  9846.         else
  9847.             return FALSE;
  9848.         end if;
  9849.         when READ => 
  9850.         STOP;
  9851.         return FALSE;
  9852.         when LIST =>  return FALSE;
  9853.     end case;
  9854.  
  9855.     end MODIFY;
  9856.  
  9857. -------------------------------------------------------------------------------
  9858. --                        procedure INITIALIZE_STATUS                        --
  9859. -------------------------------------------------------------------------------
  9860.     procedure INITIALIZE_STATUS is
  9861.     begin
  9862.     for I in 1 .. TABLE_NO loop
  9863.         TABLE (I).NAME := "          ";
  9864.         TABLE (I).TABLE_STATUS.TABLE_IS_LOCKED := FALSE;
  9865.         TABLE (I).TABLE_DEFINITION.COLUMN_NUMBER := 0;
  9866.         TABLE (I).TABLE_DEFINITION.COLUMN_NAMES :=
  9867.           (1 .. COL_NO => "          ");
  9868.         TABLE (I).TABLE_DEFINITION.IN_RECORD :=
  9869.           (1 .. COL_NO => "          ");
  9870.     end loop;
  9871.     end INITIALIZE_STATUS;
  9872. -------------------------------------------------------------------------------
  9873. --                        procedure UPDATE_STATUS                            --
  9874. -------------------------------------------------------------------------------
  9875.     procedure UPDATE_STATUS is
  9876.  
  9877. -- UPDATE_STATUS displays the values contained in the SHARE and
  9878. -- TABLE_DESCRIPTOR packages, and updates them according to the
  9879. -- user's inputs.
  9880. -- The displayed values are organized in three kinds of screens
  9881. -- called screen 1, screen 2 and screen 3.
  9882. -- Screen 1 is the main descriptor and appears one time for
  9883. -- the whole package description;
  9884. -- Screen 2 appears one time for each column of each locked
  9885. -- table;
  9886. -- Screen 3 appears one time for each locked table and describes
  9887. -- the current status of the table.
  9888.  
  9889.     GOT                     : STRING (1 .. 40);
  9890.     LAST, K                 : INTEGER;
  9891.     ENUM_ITEM_ACCESS_OBJECT : ENUM_ITEM_ACCESS;
  9892.     begin
  9893.  
  9894. --------------------verify EMBEDDED_INTERFACE_IS_IN_USE-------------------
  9895.  
  9896.     PARAMETER := TABLE_DESCRIPTORS;
  9897.     NEWPAGE;
  9898.     SCREEN_POS (0, 15);
  9899.     PUT_LINE (" DAMES_STATUS.EMBEDDED_INTERFACE_IS_IN_USE : " &
  9900.           BOOLEAN'IMAGE (EMBEDDED_INTERFACE_IS_IN_USE));
  9901.     if MODIFY then
  9902.         SCREEN_POS (45, 15);
  9903.         GET_LINE (GOT, LAST);
  9904.         if LAST /= 0 then
  9905.         EMBEDDED_INTERFACE_IS_IN_USE := BOOLEAN'VALUE (GOT (1 .. LAST));
  9906.         end if;
  9907.     end if;
  9908.  
  9909.  
  9910. ----------------------display SCREEN 1------------------------------------
  9911.  
  9912.  
  9913.     NEWPAGE;
  9914.     SCREEN_POS (0, 4);
  9915.     PUT_LINE ("     TABLE     NAME      COLUMN_NUMBER        SORTED");
  9916.     NEW_LINE (5);
  9917.  
  9918.     for I in 1 .. TABLE_NO loop
  9919.         PUT ("     " & INTEGER'IMAGE (I));
  9920.         SET_COL (14);
  9921.         PUT (TABLE (I).NAME & "    " &
  9922.          INTEGER'IMAGE (TABLE (I).TABLE_DEFINITION.COLUMN_NUMBER));
  9923.         SET_COL (49);
  9924.         PUT_LINE (BOOLEAN'IMAGE (TABLE (I).TABLE_DEFINITION.SORTED));
  9925.         NEW_LINE;
  9926.     end loop;
  9927.  
  9928.     SCREEN_POS (0, 19);
  9929.     PUT_LINE ("  SHARE.A_DATABASE_IS_OPEN : " &
  9930.           BOOLEAN'IMAGE (A_DATABASE_IS_OPEN));
  9931.     PUT_LINE ("  SHARE.OPEN_DATABASE_NAME : " & OPEN_DATABASE_NAME);
  9932.  
  9933. -------------------------modify SCREEN 1----------------------------------
  9934.  
  9935.     if MODIFY then
  9936.         for I in 1 .. TABLE_NO loop
  9937.         SCREEN_POS (13, 8 + 2 * I);
  9938.         GOT := (others => ' ');
  9939.         GET_LINE (GOT (1 .. 10), LAST);
  9940.  
  9941.         if LAST /= 0 then
  9942.             TABLE (I).NAME := GOT (1 .. 10);
  9943.         end if;
  9944.  
  9945.         SCREEN_POS (28, 8 + 2 * I);
  9946.         GOT := (others => ' ');
  9947.         GET_LINE (GOT (1 .. 5), LAST);
  9948.  
  9949.         if LAST /= 0 then
  9950.             TABLE (I).TABLE_DEFINITION.COLUMN_NUMBER :=
  9951.               INTEGER'VALUE (GOT (1 .. 5));
  9952.         end if;
  9953.  
  9954.         SCREEN_POS (48, 8 + 2 * I);
  9955.         GOT := (others => ' ');
  9956.         GET_LINE (GOT (1 .. 6), LAST);
  9957.  
  9958.         if LAST /= 0 then
  9959.             TABLE (I).TABLE_DEFINITION.SORTED :=
  9960.               BOOLEAN'VALUE (GOT (1 .. 6));
  9961.         end if;
  9962.  
  9963.         end loop;
  9964.  
  9965.         SCREEN_POS (29, 19);
  9966.         GET_LINE (GOT, LAST);
  9967.         if LAST /= 0 then
  9968.         A_DATABASE_IS_OPEN := BOOLEAN'VALUE (GOT (1 .. LAST));
  9969.         end if;
  9970.         SCREEN_POS (29, 20);
  9971.         GET_LINE (GOT, LAST);
  9972.         if LAST /= 0 then
  9973.         OPEN_DATABASE_NAME := GOT (1 .. LAST) & (LAST + 1 .. 10 => ' ');
  9974.         end if;
  9975.     end if;
  9976.  
  9977. ------------------------display SCREEN 2----------------------------------
  9978.  
  9979.  
  9980.     for I in 1 .. TABLE_NO loop
  9981.         for J in 1 .. TABLE (I).TABLE_DEFINITION.COLUMN_NUMBER loop
  9982.         NEWPAGE;
  9983.         SCREEN_POS (0, 4);
  9984.         PUT_LINE ("          TABLE " & INTEGER'IMAGE (I) &
  9985.               "          COLUMN " & INTEGER'IMAGE (J));
  9986.         NEW_LINE;
  9987.         PUT ("NAME : " & TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (J) &
  9988.              "      INDEX : " &
  9989.              INTEGER'IMAGE
  9990.                (TABLE (I).TABLE_DEFINITION.COLUMN_INDEX (J)));
  9991.         SET_COL (44);
  9992.         PUT ("TYPE : " &
  9993.              INTEGER'IMAGE
  9994.                (TABLE (I).TABLE_DEFINITION.COLUMN_TYPES (J)));
  9995.         SET_COL (62);
  9996.         PUT_LINE ("LENGTH : " &
  9997.               INTEGER'IMAGE
  9998.                 (TABLE (I).TABLE_DEFINITION.COLUMN_LENGTH (J)));
  9999.  
  10000.         if TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J) = null then
  10001.             PUT_LINE ("CONSTRAINT (null / new) : null     ACCESSED CONSTRAINT :");
  10002.         else
  10003.             PUT_LINE ("CONSTRAINT (null / new) : new      ACCESSED CONSTRAINT : " &
  10004.                   TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J).all
  10005.                  (1 .. 10) &
  10006.                   TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J).all
  10007.                  (RANGE_SIZE + 1 .. RANGE_SIZE + 10));
  10008.         end if;
  10009.  
  10010.         PUT_LINE ("IN_RECORD : " &
  10011.               TABLE (I).TABLE_DEFINITION.IN_RECORD (J));
  10012.         ENUM_ITEM_ACCESS_OBJECT :=
  10013.           TABLE (I).TABLE_DEFINITION.ENUM_TYPES (J);
  10014.         NEW_LINE;
  10015.  
  10016.         if ENUM_ITEM_ACCESS_OBJECT = null then
  10017.             PUT_LINE ("ENUMERATION DEFINITION (null / new) : null");
  10018.             PUT_LINE ("              ENUM_IMAGE                      OTHER (null / new)");
  10019.         else
  10020.             PUT_LINE ("ENUMERATION DEFINITION (null / new) : new");
  10021.             PUT_LINE ("              ENUM_IMAGE                      OTHER (null / new)");
  10022.             PUT (ENUM_ITEM_ACCESS_OBJECT.ENUM_IMAGE);
  10023.             ENUM_ITEM_ACCESS_OBJECT :=
  10024.               ENUM_ITEM_ACCESS_OBJECT.all.OTHER;
  10025.  
  10026.             while ENUM_ITEM_ACCESS_OBJECT /= null loop
  10027.             PUT_LINE ("          new");
  10028.             PUT (ENUM_ITEM_ACCESS_OBJECT.ENUM_IMAGE);
  10029.             ENUM_ITEM_ACCESS_OBJECT :=
  10030.               ENUM_ITEM_ACCESS_OBJECT.all.OTHER;
  10031.             end loop;
  10032.  
  10033.             PUT_LINE ("          null");
  10034.  
  10035.         end if;
  10036. ---------------------modify SCREEN 2--------------------------------------
  10037.  
  10038.  
  10039.         if MODIFY then
  10040.             SCREEN_POS (7, 6);
  10041.             GOT := (others => ' ');
  10042.             GET_LINE (GOT (1 .. 10), LAST);
  10043.  
  10044.             if LAST /= 0 then
  10045.             TABLE (I).TABLE_DEFINITION.COLUMN_NAMES (J) :=
  10046.               GOT (1 .. 10);
  10047.             end if;
  10048.  
  10049.             SCREEN_POS (32, 6);
  10050.             GOT := (others => ' ');
  10051.             GET_LINE (GOT (1 .. 5), LAST);
  10052.  
  10053.             if LAST /= 0 then
  10054.             TABLE (I).TABLE_DEFINITION.COLUMN_INDEX (J) :=
  10055.               INTEGER'VALUE (GOT (1 .. 5));
  10056.             end if;
  10057.  
  10058.             SCREEN_POS (51, 6);
  10059.             GOT := (others => ' ');
  10060.             GET_LINE (GOT (1 .. 5), LAST);
  10061.  
  10062.             if LAST /= 0 then
  10063.             TABLE (I).TABLE_DEFINITION.COLUMN_TYPES (J) :=
  10064.               INTEGER'VALUE (GOT (1 .. 5));
  10065.             end if;
  10066.  
  10067.             SCREEN_POS (71, 6);
  10068.             GOT := (others => ' ');
  10069.             GET_LINE (GOT (1 .. 5), LAST);
  10070.  
  10071.             if LAST /= 0 then
  10072.             TABLE (I).TABLE_DEFINITION.COLUMN_LENGTH (J) :=
  10073.               INTEGER'VALUE (GOT (1 .. 5));
  10074.             end if;
  10075.  
  10076.             SCREEN_POS (26, 7);
  10077.             GOT := (others => ' ');
  10078.             GET_LINE (GOT (1 .. 5), LAST);
  10079.  
  10080.             if GOT (1 .. 4) = "null" then
  10081.             TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J) := null;
  10082.  
  10083.             elsif GOT (1 .. 3) = "new" then
  10084.             TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J) :=
  10085.               new STRING (1 .. 2 * RANGE_SIZE);
  10086.             SCREEN_POS (57, 7);
  10087.             GOT := (others => ' ');
  10088.             GET_LINE (GOT (1 .. 20), LAST);
  10089.  
  10090.             if LAST /= 0 then
  10091.                 TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J).all :=
  10092.                   GOT (1 .. 10) & (11 .. RANGE_SIZE => ' ') &
  10093.                   GOT (11 .. 20) &
  10094.                   (RANGE_SIZE + 11 .. 2 * RANGE_SIZE => ' ');
  10095.             end if;
  10096.             else
  10097.             if TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J) /=
  10098.                null then
  10099.                 SCREEN_POS (57, 7);
  10100.                 GOT := (others => ' ');
  10101.                 GET_LINE (GOT (1 .. 20), LAST);
  10102.  
  10103.                 if LAST /= 0 then
  10104.                 TABLE (I).TABLE_DEFINITION.CONSTRAINTS
  10105.                    (J).all :=
  10106.                   GOT (1 .. 10) & (11 .. RANGE_SIZE => ' ') &
  10107.                   GOT (11 .. 20) &
  10108.                   (RANGE_SIZE + 11 .. 2 * RANGE_SIZE => ' ');
  10109.                 end if;
  10110.             end if;
  10111.             end if;
  10112.  
  10113.             SCREEN_POS (12, 8);
  10114.             GOT := (others => ' ');
  10115.             GET_LINE (GOT (1 .. 10), LAST);
  10116.  
  10117.             if LAST /= 0 then
  10118.             TABLE (I).TABLE_DEFINITION.IN_RECORD (J) :=
  10119.               GOT (1 .. 10);
  10120.             end if;
  10121.  
  10122.             SCREEN_POS (38, 10);
  10123.             GOT := (others => ' ');
  10124.             GET_LINE (GOT (1 .. 5), LAST);
  10125.  
  10126.             if GOT (1 .. 4) = "null" then
  10127.             TABLE (I).TABLE_DEFINITION.ENUM_TYPES (J) := null;
  10128.  
  10129.             elsif GOT (1 .. 3) = "new" then
  10130.             TABLE (I).TABLE_DEFINITION.ENUM_TYPES (J) :=
  10131.               new ENUM_ITEM;
  10132.             end if;
  10133.  
  10134.             if TABLE (I).TABLE_DEFINITION.ENUM_TYPES (J) /= null then
  10135.             SCREEN_POS (0, 12);
  10136.             GOT := (others => ' ');
  10137.             GET_LINE (GOT (1 .. 40), LAST);
  10138.  
  10139.             if LAST /= 0 then
  10140.                 TABLE (I).TABLE_DEFINITION.ENUM_TYPES (J).all
  10141.                  .ENUM_IMAGE := GOT (1 .. IMAGE_SZ);
  10142.             end if;
  10143.  
  10144.             ENUM_ITEM_ACCESS_OBJECT :=
  10145.               TABLE (I).TABLE_DEFINITION.ENUM_TYPES (J);
  10146.             K := 12;
  10147.  
  10148.             loop
  10149.                 SCREEN_POS (50, K);
  10150.                 GOT := (others => ' ');
  10151.                 GET_LINE (GOT (1 .. 5), LAST);
  10152.  
  10153.                 if GOT (1 .. 4) = "null" then
  10154.                 ENUM_ITEM_ACCESS_OBJECT.all.OTHER := null;
  10155.                 exit;
  10156.  
  10157.                 elsif GOT (1 .. 3) = "new" then
  10158.                 ENUM_ITEM_ACCESS_OBJECT.all.OTHER :=
  10159.                   new ENUM_ITEM;
  10160.  
  10161.                 elsif ENUM_ITEM_ACCESS_OBJECT.all.OTHER = null then
  10162.                 exit;
  10163.                 else
  10164.                 null;
  10165.                 end if;
  10166.  
  10167.                 K := K + 1;
  10168.                 ENUM_ITEM_ACCESS_OBJECT :=
  10169.                   ENUM_ITEM_ACCESS_OBJECT.all.OTHER;
  10170.                 SCREEN_POS (0, K);
  10171.                 GOT := (others => ' ');
  10172.                 GET_LINE (GOT (1 .. 40), LAST);
  10173.  
  10174.                 if LAST /= 0 then
  10175.                 ENUM_ITEM_ACCESS_OBJECT.all.ENUM_IMAGE :=
  10176.                   GOT (1 .. IMAGE_SZ);
  10177.                 end if;
  10178.             end loop;
  10179.  
  10180.             end if;
  10181.         end if;
  10182.         end loop;
  10183.     end loop;
  10184.  
  10185. ---------------------------display SCREEN 3-------------------------------
  10186.  
  10187.  
  10188.  
  10189.     for I in 1 .. TABLE_NO loop
  10190.         if TABLE (I).NAME /= "          " then
  10191.         NEWPAGE;
  10192.         SCREEN_POS (30, 4);
  10193.         PUT_LINE ("TABLE " & TABLE (I).NAME);
  10194.         SCREEN_POS (0, 6);
  10195.         PUT ("     TABLE_IS_LOCKED : " &
  10196.              BOOLEAN'IMAGE (TABLE (I).TABLE_STATUS.TABLE_IS_LOCKED));
  10197.         SCREEN_POS (50, 6);
  10198.         PUT_LINE ("CURRENT_LOCK : " &
  10199.               ACCESS_MODE_TYPE'IMAGE
  10200.                 (TABLE (I).TABLE_STATUS.CURRENT_LOCK));
  10201.         PUT ("     DESCR :" &
  10202.              INTEGER'IMAGE (TABLE (I).TABLE_STATUS.DESCR));
  10203.         SCREEN_POS (40, 7);
  10204.         PUT_LINE ("FIND_STATUS : " &
  10205.               FIND_STATUS_TYPE'IMAGE
  10206.                 (TABLE (I).TABLE_STATUS.FIND_STATUS));
  10207.         PUT ("     CURRENT_ROW :" &
  10208.              INTEGER'IMAGE (TABLE (I).TABLE_STATUS.CURRENT_ROW (1)));
  10209.         SET_COL (29);
  10210.         PUT (INTEGER'IMAGE (TABLE (I).TABLE_STATUS.CURRENT_ROW (2)));
  10211.         SET_COL (39);
  10212.         PUT_LINE (INTEGER'IMAGE
  10213.                 (TABLE (I).TABLE_STATUS.CURRENT_ROW (3)));
  10214.  
  10215.         if TABLE (I).TABLE_STATUS.SELECTION_CRITERION = null then
  10216.             PUT_LINE ("          SELECTION_CRITERION (null / new) : null");
  10217.             PUT_LINE ("                   COLUMN_ID    : ");
  10218.             PUT_LINE ("                   KEY_MATCH    : ");
  10219.             PUT_LINE ("                   COLUMN_VALUE : ");
  10220.             NEW_LINE (4);
  10221.             PUT_LINE ("                   MEANINGFUL   : ");
  10222.             PUT_LINE ("                   USER_OPERATOR: ");
  10223.             PUT_LINE ("                   TREE_OPERATOR: ");
  10224.             PUT_LINE ("                   FIRST_CHILD  : ");
  10225.             PUT_LINE ("                   SECOND_CHILD : ");
  10226.             PUT_LINE ("                   OTHER        : ");
  10227.         else
  10228.             PUT_LINE ("          SELECTION_CRITERION (null / new) : new ");
  10229.             PUT_LINE ("                   COLUMN_ID    :" &
  10230.                   INTEGER'IMAGE
  10231.                 (TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10232.                   .COLUMN_ID));
  10233.             PUT_LINE ("                   KEY_MATCH    : " &
  10234.                   KEY_MATCH_TYPE'IMAGE
  10235.                 (TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10236.                   .KEY_MATCH));
  10237.             PUT ("                   COLUMN_VALUE : ");
  10238.  
  10239.             for II in 1 .. 4 loop
  10240.             for JJ in 1 .. 3 loop
  10241.                 SET_COL (POSITIVE_COUNT (31 + 15 * JJ));
  10242.                 PUT (INTEGER'IMAGE
  10243.                    (TABLE (I).TABLE_STATUS
  10244.                      .SELECTION_CRITERION.all.COLUMN_VALUE
  10245.                        (6 * II + JJ - 6)));
  10246.             end loop;
  10247.  
  10248.             NEW_LINE;
  10249.  
  10250.             for JJ in 1 .. 3 loop
  10251.                 SET_COL (POSITIVE_COUNT (15 * JJ - 14));
  10252.                 PUT (INTEGER'IMAGE
  10253.                    (TABLE (I).TABLE_STATUS
  10254.                      .SELECTION_CRITERION.all.COLUMN_VALUE
  10255.                        (6 * II + JJ - 3)));
  10256.             end loop;
  10257.             end loop;
  10258.  
  10259.             SET_COL (46);
  10260.             PUT_LINE (INTEGER'IMAGE
  10261.                 (TABLE (I).TABLE_STATUS.SELECTION_CRITERION
  10262.                   .COLUMN_VALUE (25)));
  10263.             PUT_LINE ("                   MEANINGFUL   :" &
  10264.                   INTEGER'IMAGE
  10265.                 (TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10266.                   .MEANINGFUL));
  10267.             PUT_LINE ("                   USER_OPERATOR: " &
  10268.                   OPERATOR_TYPE'IMAGE
  10269.                 (TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10270.                   .USER_OPERATOR));
  10271.             PUT_LINE ("                   TREE_OPERATOR: " &
  10272.                   OPERATOR_TYPE'IMAGE
  10273.                 (TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10274.                   .TREE_OPERATOR));
  10275.  
  10276.             if TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10277.             .FIRST_CHILD = null then
  10278.             PUT_LINE ("                   FIRST_CHILD  : null");
  10279.             else
  10280.             PUT_LINE ("                   FIRST_CHILD  : new ");
  10281.             end if;
  10282.  
  10283.             if TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10284.             .SECOND_CHILD = null then
  10285.             PUT_LINE ("                   SECOND_CHILD : null");
  10286.             else
  10287.             PUT_LINE ("                   SECOND_CHILD : new ");
  10288.             end if;
  10289.  
  10290.             if TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all.OTHER =
  10291.                null then
  10292.             PUT_LINE ("                   OTHER        : null");
  10293.             else
  10294.             PUT_LINE ("                   OTHER        : new ");
  10295.             end if;
  10296.         end if;
  10297.  
  10298. --------------------------------modify SCREEN 3---------------------------
  10299.  
  10300.         if MODIFY then
  10301.             SCREEN_POS (23, 6);
  10302.             GOT := (others => ' ');
  10303.             GET_LINE (GOT (1 .. 6), LAST);
  10304.  
  10305.             if LAST /= 0 then
  10306.             TABLE (I).TABLE_STATUS.TABLE_IS_LOCKED :=
  10307.               BOOLEAN'VALUE (GOT (1 .. 6));
  10308.             end if;
  10309.  
  10310.             SCREEN_POS (65, 6);
  10311.             GOT := (others => ' ');
  10312.             GET_LINE (GOT (1 .. 10), LAST);
  10313.  
  10314.             if LAST /= 0 then
  10315.             TABLE (I).TABLE_STATUS.CURRENT_LOCK :=
  10316.               ACCESS_MODE_TYPE'VALUE (GOT (1 .. 10));
  10317.             end if;
  10318.  
  10319.             SCREEN_POS (13, 7);
  10320.             GOT := (others => ' ');
  10321.             GET_LINE (GOT (1 .. 5), LAST);
  10322.  
  10323.             if LAST /= 0 then
  10324.             TABLE (I).TABLE_STATUS.DESCR :=
  10325.               INTEGER'VALUE (GOT (1 .. 5));
  10326.             end if;
  10327.  
  10328.             SCREEN_POS (54, 7);
  10329.             GOT := (others => ' ');
  10330.             GET_LINE (GOT (1 .. 10), LAST);
  10331.  
  10332.             if LAST /= 0 then
  10333.             TABLE (I).TABLE_STATUS.FIND_STATUS :=
  10334.               FIND_STATUS_TYPE'VALUE (GOT (1 .. 10));
  10335.             end if;
  10336.  
  10337.             SCREEN_POS (19, 8);
  10338.             GOT := (others => ' ');
  10339.             GET_LINE (GOT (1 .. 5), LAST);
  10340.  
  10341.             if LAST /= 0 then
  10342.             TABLE (I).TABLE_STATUS.CURRENT_ROW (1) :=
  10343.               INTEGER'VALUE (GOT (1 .. 5));
  10344.             end if;
  10345.  
  10346.             SCREEN_POS (29, 8);
  10347.             GOT := (others => ' ');
  10348.             GET_LINE (GOT (1 .. 5), LAST);
  10349.  
  10350.             if LAST /= 0 then
  10351.             TABLE (I).TABLE_STATUS.CURRENT_ROW (2) :=
  10352.               INTEGER'VALUE (GOT (1 .. 5));
  10353.             end if;
  10354.  
  10355.             SCREEN_POS (39, 8);
  10356.             GOT := (others => ' ');
  10357.             GET_LINE (GOT (1 .. 5), LAST);
  10358.  
  10359.             if LAST /= 0 then
  10360.             TABLE (I).TABLE_STATUS.CURRENT_ROW (3) :=
  10361.               INTEGER'VALUE (GOT (1 .. 5));
  10362.             end if;
  10363.  
  10364.             SCREEN_POS (45, 9);
  10365.             GOT := (others => ' ');
  10366.             GET_LINE (GOT (1 .. 5), LAST);
  10367.  
  10368.             if GOT (1 .. 4) = "null" then
  10369.             TABLE (I).TABLE_STATUS.SELECTION_CRITERION := null;
  10370.  
  10371.             elsif GOT (1 .. 3) = "new" then
  10372.             TABLE (I).TABLE_STATUS.SELECTION_CRITERION := new NODE;
  10373.             end if;
  10374.  
  10375.             if TABLE (I).TABLE_STATUS.SELECTION_CRITERION /= null then
  10376.             SCREEN_POS (34, 10);
  10377.             GOT := (others => ' ');
  10378.             GET_LINE (GOT (1 .. 5), LAST);
  10379.  
  10380.             if LAST /= 0 then
  10381.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10382.                  .COLUMN_ID := INTEGER'VALUE (GOT (1 .. 5));
  10383.             end if;
  10384.  
  10385.             SCREEN_POS (34, 11);
  10386.             GOT := (others => ' ');
  10387.             GET_LINE (GOT (1 .. 20), LAST);
  10388.  
  10389.             if LAST /= 0 then
  10390.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10391.                  .KEY_MATCH := KEY_MATCH_TYPE'VALUE (GOT (1 .. 20));
  10392.             end if;
  10393.  
  10394.             for II in 1 .. 4 loop
  10395.  
  10396.                 for JJ in 1 .. 3 loop
  10397.  
  10398.                 SCREEN_POS (31 + 15 * JJ, 11 + II);
  10399.                 GOT := (others => ' ');
  10400.                 GET_LINE (GOT (1 .. 10), LAST);
  10401.  
  10402.                 if LAST /= 0 then
  10403.                     TABLE (I).TABLE_STATUS
  10404.                      .SELECTION_CRITERION.all.COLUMN_VALUE
  10405.                        (6 * II + JJ - 6) :=
  10406.                       INTEGER'VALUE (GOT (1 .. 10));
  10407.                 end if;
  10408.  
  10409.                 end loop;
  10410.                 -- jj
  10411.  
  10412.                 for JJ in 1 .. 3 loop
  10413.  
  10414.                 SCREEN_POS (15 * JJ - 14, 12 + II);
  10415.                 GOT := (others => ' ');
  10416.                 GET_LINE (GOT (1 .. 10), LAST);
  10417.  
  10418.                 if LAST /= 0 then
  10419.                     TABLE (I).TABLE_STATUS
  10420.                      .SELECTION_CRITERION.all.COLUMN_VALUE
  10421.                        (6 * II + JJ - 3) :=
  10422.                       INTEGER'VALUE (GOT (1 .. 10));
  10423.                 end if;
  10424.  
  10425.                 end loop;
  10426.                 -- jj
  10427.  
  10428.             end loop;
  10429.             -- ii
  10430.  
  10431.             SCREEN_POS (46, 16);
  10432.             GOT := (others => ' ');
  10433.             GET_LINE (GOT (1 .. 10), LAST);
  10434.  
  10435.             if LAST /= 0 then
  10436.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10437.                  .COLUMN_VALUE (25) :=
  10438.                   INTEGER'VALUE (GOT (1 .. 10));
  10439.             end if;
  10440.  
  10441.             SCREEN_POS (34, 17);
  10442.             GOT := (others => ' ');
  10443.             GET_LINE (GOT (1 .. 5), LAST);
  10444.  
  10445.             if LAST /= 0 then
  10446.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10447.                  .MEANINGFUL := INTEGER'VALUE (GOT (1 .. 5));
  10448.             end if;
  10449.  
  10450.             SCREEN_POS (34, 18);
  10451.             GOT := (others => ' ');
  10452.             GET_LINE (GOT (1 .. 13), LAST);
  10453.  
  10454.             if LAST /= 0 then
  10455.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10456.                  .USER_OPERATOR :=
  10457.                   OPERATOR_TYPE'VALUE (GOT (1 .. 13));
  10458.             end if;
  10459.  
  10460.             SCREEN_POS (34, 19);
  10461.             GOT := (others => ' ');
  10462.             GET_LINE (GOT (1 .. 13), LAST);
  10463.  
  10464.             if LAST /= 0 then
  10465.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10466.                  .TREE_OPERATOR :=
  10467.                   OPERATOR_TYPE'VALUE (GOT (1 .. 13));
  10468.             end if;
  10469.  
  10470.             SCREEN_POS (34, 20);
  10471.             GOT := (others => ' ');
  10472.             GET_LINE (GOT (1 .. 5), LAST);
  10473.  
  10474.             if LAST /= 0 then
  10475.                 if GOT (1 .. 4) = "null" then
  10476.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10477.                  .FIRST_CHILD := null;
  10478.  
  10479.                 elsif GOT (1 .. 3) = "new" then
  10480.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10481.                  .FIRST_CHILD := new NODE;
  10482.                 end if;
  10483.             end if;
  10484.  
  10485.             SCREEN_POS (34, 21);
  10486.             GOT := (others => ' ');
  10487.             GET_LINE (GOT (1 .. 5), LAST);
  10488.  
  10489.             if LAST /= 0 then
  10490.                 if GOT (1 .. 4) = "null" then
  10491.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10492.                  .SECOND_CHILD := null;
  10493.  
  10494.                 elsif GOT (1 .. 3) = "new" then
  10495.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10496.                  .SECOND_CHILD := new NODE;
  10497.                 end if;
  10498.             end if;
  10499.  
  10500.             SCREEN_POS (34, 22);
  10501.             GOT := (others => ' ');
  10502.             GET_LINE (GOT (1 .. 5), LAST);
  10503.  
  10504.             if LAST /= 0 then
  10505.                 if GOT (1 .. 4) = "null" then
  10506.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10507.                  .OTHER := null;
  10508.  
  10509.                 elsif GOT (1 .. 3) = "new" then
  10510.                 TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all
  10511.                  .OTHER := new NODE;
  10512.                 end if;
  10513.             end if;
  10514.  
  10515.             end if;
  10516.         end if;
  10517.         end if;
  10518.     end loop;
  10519.     PARAMETER := IN_PARAMETERS;
  10520.     end UPDATE_STATUS;
  10521. end DISPLAY;
  10522. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  10523. --toolspec.txt
  10524. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  10525. with CONSTANTS;
  10526. use CONSTANTS;
  10527. with SHARE;
  10528. with TABLE_DESCRIPTOR;
  10529. use TABLE_DESCRIPTOR;
  10530. with BOTH_VARIABLES;
  10531. use BOTH_VARIABLES;
  10532. with LL_DAMES;
  10533. use LL_DAMES;
  10534. with INSTANTIATED;
  10535. use INSTANTIATED;
  10536.  
  10537. package TOOLS is
  10538.  
  10539. --***************************************************************************--
  10540. --                                  types                                    --
  10541. --***************************************************************************--
  10542.  
  10543.     type TEST is
  10544.     record
  10545.         NAME    : STRING (1 .. 5);
  10546.         IS_OPEN : BOOLEAN;
  10547.     end record;
  10548.  
  10549.     type ARR is array (TEST_CASE_NUMBER) of TEST;
  10550.  
  10551.     type POINTER_TABLE is
  10552.     record
  10553.         IS_EMPTY  : BOOLEAN;
  10554.         IS_FULL   : BOOLEAN;
  10555.         TEST_CASE : ARR;
  10556.     end record;
  10557.  
  10558.     type LOST_SWITCH_TYPE is (LOAD, STORE);
  10559.  
  10560. --***************************************************************************--
  10561. --                                 variables                                 --
  10562. --***************************************************************************--
  10563.  
  10564.     PT_TABLE : POINTER_TABLE;
  10565.     procedure RDWR_POINTER_TABLE (LOST_SWITCH : LOST_SWITCH_TYPE);
  10566.  
  10567. --************************************************************************
  10568. --**                                                                    **
  10569. --**   UNIT NAME :               RDWR_POINTER_TABLE                     **
  10570. --**   ~~~~~~~~~~~                                                      **
  10571. --**                                                                    **
  10572. --** DESCRIPTION ------------------------------------------------------ **
  10573. --**                                                                    **
  10574. --**   This procedure reads or writes the pointer table.                **
  10575. --**                                                                    **
  10576. --** INPUT ------------------------------------------------------------ **
  10577. --**                                                                    **
  10578. --**   LOST_SWITCH if lost_switch = load the procedure read the pointer **
  10579. --**                                table.                              **
  10580. --**               if lost_switch = store the procedure write the       **
  10581. --**                                pointer table.                      **
  10582. --**                                                                    **
  10583. --** OUTPUT ----------------------------------------------------------- **
  10584. --**                                                                    **
  10585. --** EXCEPTIONS ------------------------------------------------------- **
  10586. --**                                                                    **
  10587. --************************************************************************
  10588.     subtype LOCK_LIST_LENGTH is POSITIVE range 1 .. 3;
  10589.     LENGTH_1 : constant := 10;
  10590.  
  10591.     type IN_PARAMETER (NUMBER : INTERFACE_NUMBER) is
  10592.     record
  10593.         case NUMBER is
  10594.         when 0 | 3 => 
  10595.             DB_NAME : STRING (1 .. LENGTH_1) := "string....";
  10596.         when 1 => 
  10597.             COMMAND : STRING (1 .. LENGTH_1) := "string....";
  10598.         when 2 | 7 | 8 => 
  10599.             null;
  10600.         when 5 => 
  10601.             LLL       : LOCK_LIST_LENGTH := 3;
  10602.             LOCK_LIST : LOCK_LIST_TYPE (1 .. 3) :=
  10603.                 (others =>
  10604.                    (TABLE_NAME  => "string....",
  10605.                     ACCESS_MODE => EXCLUSIVE));
  10606.         when others => 
  10607.             TABLE_NAME : STRING (1 .. LENGTH_1) := "string....";
  10608.             case NUMBER is
  10609.             when 4 => 
  10610.                 COLUMN_LIST : STRING (1 .. 200) :=
  10611.                       ('s', 't', 'r', 'i', 'n', 'g',
  10612.                        others => '.');
  10613.             when 20 => 
  10614.                 ITM : RECD;
  10615.             when 09 | 10 | 11 | 17 | 19 => 
  10616.                 COLUMN_NAME : STRING (1 .. LENGTH_1) :=
  10617.                       "string....";
  10618.                 case NUMBER is
  10619.                 when 09 | 10 | 11 => 
  10620.                     KEY_MATCH    : KEY_MATCH_TYPE :=
  10621.                            GREATER_OR_EQUAL;
  10622.                     COLUMN_VALUE : RECD;
  10623.                 when 19 => 
  10624.                     ITEM : RECD;
  10625.                 when others => 
  10626.                     null;
  10627.                 end case;
  10628.             when others => 
  10629.                 null;
  10630.             end case;
  10631.         end case;
  10632.     end record;
  10633.  
  10634.     subtype IN_PARAMETER_00 is IN_PARAMETER (00);
  10635.     subtype IN_PARAMETER_01 is IN_PARAMETER (01);
  10636.     subtype IN_PARAMETER_04 is IN_PARAMETER (04);
  10637.     subtype IN_PARAMETER_05 is IN_PARAMETER (05);
  10638.     subtype IN_PARAMETER_06 is IN_PARAMETER (06);
  10639.     subtype IN_PARAMETER_09 is IN_PARAMETER (09);
  10640.     subtype IN_PARAMETER_17 is IN_PARAMETER (17);
  10641.     subtype IN_PARAMETER_19 is IN_PARAMETER (19);
  10642.     subtype IN_PARAMETER_20 is IN_PARAMETER (20);
  10643.     generic
  10644.     type IN_PARAMETERS is private;
  10645.     procedure RDWR_IN_PARAMETERS (LOST_SWITCH : LOST_SWITCH_TYPE;
  10646.                   ITEM_1      : in out IN_PARAMETERS);
  10647.  
  10648. --************************************************************************
  10649. --**                                                                    **
  10650. --**   UNIT NAME :               RDWR_IN_PARAMETERS                     **
  10651. --**   ~~~~~~~~~~~                                                      **
  10652. --**                                                                    **
  10653. --** DESCRIPTION ------------------------------------------------------ **
  10654. --**                                                                    **
  10655. --**   This procedure reads or writes the interface procedure           **
  10656. --**   in_parameters.                                                   **
  10657. --**                                                                    **
  10658. --** INPUT ------------------------------------------------------------ **
  10659. --**                                                                    **
  10660. --**   LOST_SWITCH if lost_switch = load the procedure read the         **
  10661. --**                                interface procedure in_parameters.  **
  10662. --**               if lost_switch = store the procedure write the       **
  10663. --**                                interface procedure in_parameters.  **
  10664. --**                                                                    **
  10665. --**   ITEM_1 this is the structure of the interface procedure          **
  10666. --**          in_parameters.                                            **
  10667. --**                                                                    **
  10668. --** OUTPUT ----------------------------------------------------------- **
  10669. --**                                                                    **
  10670. --** EXCEPTIONS ------------------------------------------------------- **
  10671. --**                                                                    **
  10672. --************************************************************************
  10673.     type OUT_PARAMETER (NUMBER : ACCESS_NUMBER) is
  10674.     record
  10675.         case NUMBER is
  10676.         when 0 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 17 | 18 |
  10677.              20 | 21 | 22 | 23 | 25 | 26 | 28 | 30 => 
  10678.             A : INTEGER := 0;
  10679.             case NUMBER is
  10680.             when 4 | 6 | 7 | 11 | 16 | 17 | 25 => 
  10681.                 B : TIDD_TYPE := (others => 1);
  10682.                 case NUMBER is
  10683.                 when 4 => 
  10684.                     C : INTEGER_ARRAY_TYPE (1 .. 60) :=
  10685.                     (others => 1);
  10686.                     D : INTEGER_ARRAY_TYPE (1 .. 60) :=
  10687.                     (others => 1);
  10688.                 when others => 
  10689.                     null;
  10690.                 end case;
  10691.             when 5 | 8 | 15 | 21 => 
  10692.                 E : INTEGER := 0;
  10693.                 case NUMBER is
  10694.                 when 8 | 15 => 
  10695.                     F : INTEGER_ARRAY_TYPE (1 .. 60) :=
  10696.                     (others => 1);
  10697.                     case NUMBER is
  10698.                     when 8 => 
  10699.                         G : STRING (1 .. 720) :=
  10700.                         (others => '.');
  10701.                         H : INTEGER_ARRAY_TYPE (1 .. 60) :=
  10702.                         (others => 1);
  10703.                         I : INTEGER_ARRAY_TYPE (1 .. 60) :=
  10704.                         (others => 1);
  10705.                     when others => 
  10706.                         J : INTEGER := 0;
  10707.                     end case;
  10708.                 when others => 
  10709.                     null;
  10710.                 end case;
  10711.             when others => 
  10712.                 null;
  10713.             end case;
  10714.         when 14 => 
  10715.             K : INTEGER_ARRAY_TYPE (1 .. 60) := (others => 1);
  10716.         when 1 | 2 | 3 | 12 | 13 | 19 | 24 | 27 | 29 | 31 => 
  10717.             null;
  10718.         end case;
  10719.     end record;
  10720.  
  10721.     subtype OUT_PARAMETER_00 is OUT_PARAMETER (00);
  10722.     subtype OUT_PARAMETER_04 is OUT_PARAMETER (04);
  10723.     subtype OUT_PARAMETER_05 is OUT_PARAMETER (05);
  10724.     subtype OUT_PARAMETER_06 is OUT_PARAMETER (06);
  10725.     subtype OUT_PARAMETER_08 is OUT_PARAMETER (08);
  10726.     subtype OUT_PARAMETER_14 is OUT_PARAMETER (14);
  10727.     subtype OUT_PARAMETER_15 is OUT_PARAMETER (15);
  10728.     OUT_PARAMETERS_00 : OUT_PARAMETER_00;
  10729.     OUT_PARAMETERS_04 : OUT_PARAMETER_04;
  10730.     OUT_PARAMETERS_05 : OUT_PARAMETER_05;
  10731.     OUT_PARAMETERS_06 : OUT_PARAMETER_06;
  10732.     OUT_PARAMETERS_08 : OUT_PARAMETER_08;
  10733.     OUT_PARAMETERS_14 : OUT_PARAMETER_14;
  10734.     OUT_PARAMETERS_15 : OUT_PARAMETER_15;
  10735.  
  10736.     generic
  10737.     type OUT_PARAMETERS is private;
  10738.     procedure RDWR_OUT_PARAMETERS (LOST_SWITCH : LOST_SWITCH_TYPE;
  10739.                    ITEM_1      : in out OUT_PARAMETERS);
  10740.  
  10741. --************************************************************************
  10742. --**                                                                    **
  10743. --**   UNIT NAME :               RDWR_OUT_PARAMETERS                     **
  10744. --**   ~~~~~~~~~~~                                                      **
  10745. --**                                                                    **
  10746. --** DESCRIPTION ------------------------------------------------------ **
  10747. --**                                                                    **
  10748. --**   This procedure reads or writes the access procedure              **
  10749. --**   out_parameters.                                                  **
  10750. --**                                                                    **
  10751. --** INPUT ------------------------------------------------------------ **
  10752. --**                                                                    **
  10753. --**   LOST_SWITCH if lost_switch = load the procedure read the         **
  10754. --**                                access procedure out_parameters.    **
  10755. --**               if lost_switch = store the procedure write the       **
  10756. --**                                access procedure out_parameters.    **
  10757. --**                                                                    **
  10758. --**   ITEM_1 this is the structure of the access procedure             **
  10759. --**          out_parameters.                                           **
  10760. --**                                                                    **
  10761. --** OUTPUT ----------------------------------------------------------- **
  10762. --**                                                                    **
  10763. --** EXCEPTIONS ------------------------------------------------------- **
  10764. --**                                                                    **
  10765. --************************************************************************
  10766.     MAX_ENUM : constant := 3;
  10767.     -- MAX_ENUM defines the max number of enumeration items to
  10768.     -- be stored in the file for a given enumeration type; this
  10769.     -- limit does not exist in TABLE_DESCRIPTOR.
  10770.  
  10771.     type SELECTION_CRITERION_TEST_TYPE is array (1 .. TABLE_NO) of NODE;
  10772.     type CONSTRAINTS_TEST_TYPE         is array (1 .. TABLE_NO, 1 .. COL_NO)
  10773.                          of STRING
  10774.                               (1 .. 2 * RANGE_SIZE);
  10775.     type ENUM_TYPES_TEST_TYPE          is array (1 .. TABLE_NO, 1 .. COL_NO,
  10776.                          1 .. MAX_ENUM)
  10777.                          of STRING (1 .. IMAGE_SZ);
  10778.     -- the TABLE_DESCRIPTORS type is to be used for instantiating
  10779.     -- DIRECT_IO in order to manage a file which will store the
  10780.     -- values of TABLE_DESCRIPTOR and SHARE.
  10781.     type TABLE_DESCRIPTORX is
  10782.     record
  10783.         MAIN                         : TABLE_TYPE;
  10784.         SELECTION_CRITERION          : SELECTION_CRITERION_TEST_TYPE;
  10785.         CONSTRAINTS                  : CONSTRAINTS_TEST_TYPE;
  10786.         ENUM_TYPES                   : ENUM_TYPES_TEST_TYPE :=
  10787.                        (others =>
  10788.                           (others =>
  10789.                          (others => (others => ' '))));
  10790.         A_DATABASE_IS_OPEN           : BOOLEAN;
  10791.         OPEN_DATABASE_NAME           : STRING (1 .. NAME_LENGTH);
  10792.         EMBEDDED_INTERFACE_IS_IN_USE : BOOLEAN;
  10793.     end record;
  10794.  
  10795.  
  10796.  
  10797.     procedure RDWR_TABLE_DESCRIPTORS (LOST_SWITCH : LOST_SWITCH_TYPE);
  10798.  
  10799. --************************************************************************
  10800. --**                                                                    **
  10801. --**   UNIT NAME :               RDWR_TABLE_DESCRIPTORS                 **
  10802. --**   ~~~~~~~~~~~                                                      **
  10803. --**                                                                    **
  10804. --** DESCRIPTION ------------------------------------------------------ **
  10805. --**                                                                    **
  10806. --**   This procedure reads or writes the table descriptors.            **
  10807. --**                                                                    **
  10808. --** INPUT ------------------------------------------------------------ **
  10809. --**                                                                    **
  10810. --**   LOST_SWITCH if lost_switch = load the procedure read the         **
  10811. --**                                table descriptors.                  **
  10812. --**               if lost_switch = store the procedure write the       **
  10813. --**                                table descriptors.                  **
  10814. --**                                                                    **
  10815. --** OUTPUT ----------------------------------------------------------- **
  10816. --**                                                                    **
  10817. --** EXCEPTIONS ------------------------------------------------------- **
  10818. --**                                                                    **
  10819. --************************************************************************
  10820.     procedure EXECUTE_ONE_TEST_CASE;
  10821.  
  10822. --************************************************************************
  10823. --**                                                                    **
  10824. --**   UNIT NAME :               EXECUTE_ONE_TEST_CASE                  **
  10825. --**   ~~~~~~~~~~~                                                      **
  10826. --**                                                                    **
  10827. --** DESCRIPTION ------------------------------------------------------ **
  10828. --**                                                                    **
  10829. --**   This procedure tests the chosen interface procedure with the     **
  10830. --**   chosen test_case.The result of this test_case is recorded in the **
  10831. --**   log_file.                                                        **
  10832. --**                                                                    **
  10833. --** INPUT ------------------------------------------------------------ **
  10834. --**                                                                    **
  10835. --** OUTPUT ----------------------------------------------------------- **
  10836. --**                                                                    **
  10837. --** EXCEPTIONS ------------------------------------------------------- **
  10838. --**                                                                    **
  10839. --************************************************************************
  10840.     type RPGW_SWITCH_TYPE is (READ, PUT, GET, WRITE);
  10841.  
  10842.     procedure IN_PARAMETERS (RPGW_SWITCH : RPGW_SWITCH_TYPE);
  10843.  
  10844. --************************************************************************
  10845. --**                                                                    **
  10846. --**   UNIT NAME :               IN_PARAMETERS                          **
  10847. --**   ~~~~~~~~~~~                                                      **
  10848. --**                                                                    **
  10849. --** DESCRIPTION ------------------------------------------------------ **
  10850. --**                                                                    **
  10851. --**   This procedure reads or displays or acquires or writes the       **
  10852. --**   interface procedure in_parameters.                               **
  10853. --**                                                                    **
  10854. --** INPUT ------------------------------------------------------------ **
  10855. --**                                                                    **
  10856. --**   RPGW_SWITCH if rpgw_switch = read then the procedure reads the   **
  10857. --**                                interface procedure in_parameters.  **
  10858. --**               if rpgw_switch = put then the procedure displays the **
  10859. --**                                interface procedure in_parameters.  **
  10860. --**               if rpgw_switch = get then the procedure acquires the **
  10861. --**                                interface procedure in_parameters.  **
  10862. --**               if rpgw_switch = write the the procedure writes the  **
  10863. --**                                interface procedure in_parameters.  **
  10864. --**                                                                    **
  10865. --** OUTPUT ----------------------------------------------------------- **
  10866. --**                                                                    **
  10867. --** EXCEPTIONS ------------------------------------------------------- **
  10868. --**                                                                    **
  10869. --************************************************************************
  10870.     procedure OUT_PARAMETERS (RPGW_SWITCH : RPGW_SWITCH_TYPE);
  10871.  
  10872. --************************************************************************
  10873. --**                                                                    **
  10874. --**   UNIT NAME :               OUT_PARAMETERS                         **
  10875. --**   ~~~~~~~~~~~                                                      **
  10876. --**                                                                    **
  10877. --**   This procedure reads or displays or acquires or writes the       **
  10878. --**   access procedure out_parameters.                                 **
  10879. --**                                                                    **
  10880. --** INPUT ------------------------------------------------------------ **
  10881. --**                                                                    **
  10882. --**   RPGW_SWITCH if rpgw_switch = read then the procedure reads the   **
  10883. --**                                access procedure out_parameters.    **
  10884. --**               if rpgw_switch = put then the procedure displays the **
  10885. --**                                access procedure out_parameters.    **
  10886. --**               if rpgw_switch = get then the procedure acquires the **
  10887. --**                                access procedure out_parameters.    **
  10888. --**               if rpgw_switch = write the the procedure writes the  **
  10889. --**                                access procedure out_parameters.    **
  10890. --**                                                                    **
  10891. --** OUTPUT ----------------------------------------------------------- **
  10892. --**                                                                    **
  10893. --** EXCEPTIONS ------------------------------------------------------- **
  10894. --**                                                                    **
  10895. --************************************************************************
  10896.  
  10897. end TOOLS;
  10898. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  10899. --tools.txt
  10900. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  10901. with TEXT_IO;
  10902. use TEXT_IO;
  10903. with DIRECT_IO;
  10904. with DAMES_STATUS;
  10905. use DAMES_STATUS;
  10906. with DAMES;
  10907. use DAMES;
  10908. with DISPLAY;
  10909. use DISPLAY;
  10910. with CALENDAR;
  10911. use CALENDAR;
  10912.  
  10913. package body TOOLS is
  10914.  
  10915. --***************************************************************************--
  10916. --                  internal variables              --
  10917. --***************************************************************************--
  10918.  
  10919.     IN_PARAMETERS_00     : IN_PARAMETER_00;
  10920.     IN_PARAMETERS_01     : IN_PARAMETER_01;
  10921.     IN_PARAMETERS_04     : IN_PARAMETER_04;
  10922.     IN_PARAMETERS_05     : IN_PARAMETER_05;
  10923.     IN_PARAMETERS_06     : IN_PARAMETER_06;
  10924.     IN_PARAMETERS_09     : IN_PARAMETER_09;
  10925.     IN_PARAMETERS_17     : IN_PARAMETER_17;
  10926.     IN_PARAMETERS_19     : IN_PARAMETER_19;
  10927.     IN_PARAMETERS_20     : IN_PARAMETER_20;
  10928.  
  10929.     COLUMN_NUMBER        : POSITIVE;
  10930.     COLUMN_LIST          : STRING (1 .. 200);
  10931.     ENUM_STRING          : STRING (1 .. 20);
  10932.     ITEM                 : RECD;
  10933.     NO_MORE_ROW          : BOOLEAN;
  10934.     FIND_NEXT_RETURN     : BOOLEAN;
  10935.     FIND_PREVIOUS_RETURN : BOOLEAN;
  10936.     NEXT_RETURN          : BOOLEAN;
  10937.     PREVIOUS_RETURN      : BOOLEAN;
  10938.  
  10939. --***************************************************************************--
  10940. --                          internal           --
  10941. --***************************************************************************--
  10942.  
  10943. -------------------------------------------------------------------------------
  10944. --          dure GET                                 -------------------------------------------------------------------------------
  10945.     procedure GET (S : in out STRING) is
  10946.  
  10947.     GOT  : STRING (1 .. 720);
  10948.     LAST : NATURAL;
  10949.     begin
  10950.     GET_LINE (GOT, LAST);
  10951.     if LAST /= 0 then
  10952.         S := GOT (1 .. LAST) & (LAST + 1 .. S'LENGTH => ' ');
  10953.     end if;
  10954.     end GET;
  10955.  
  10956. -------------------------------------------------------------------------------
  10957. --                           procedure I_GET                                 --
  10958. -------------------------------------------------------------------------------
  10959.     procedure I_GET (I : in out INTEGER) is
  10960.  
  10961.     GOT  : STRING (1 .. 12);
  10962.     LAST : NATURAL;
  10963.     begin
  10964.     GET_LINE (GOT, LAST);
  10965.     if LAST /= 0 then
  10966.         I := INTEGER'VALUE (GOT (1 .. LAST));
  10967.     end if;
  10968.     end I_GET;
  10969.  
  10970. -------------------------------------------------------------------------------
  10971. --                           procedure F_GET                                 --
  10972. -------------------------------------------------------------------------------
  10973.     procedure F_GET (FL : in out FLOAT) is
  10974.  
  10975.     GOT    : STRING (1 .. 10);
  10976.     LAST_1 : NATURAL;
  10977.     LAST_2 : POSITIVE;
  10978.     begin
  10979.     GET_LINE (GOT, LAST_1);
  10980.     if LAST_1 /= 0 then
  10981.         F.GET (GOT (1 .. LAST_1), FL, LAST_2);
  10982.     end if;
  10983.     end F_GET;
  10984.  
  10985.     procedure RDWR_POINTER_TABLE (LOST_SWITCH : LOST_SWITCH_TYPE) is
  10986.  
  10987. --************************************************************************
  10988. --**                                                                    **
  10989. --**   UNIT NAME :               RDWR_POINTER_TABLE                     **
  10990. --**   ~~~~~~~~~~~                                                      **
  10991. --**                                                                    **
  10992. --************************************************************************
  10993.  
  10994.     package D_IO is new DIRECT_IO (POINTER_TABLE);
  10995.     use D_IO;
  10996.  
  10997.     FILE_1 : D_IO.FILE_TYPE;
  10998.  
  10999.     begin
  11000.     OPEN (FILE => FILE_1,
  11001.           MODE => D_IO.INOUT_FILE,
  11002.           NAME => "t_bed_pointer_table");
  11003.  
  11004.     case LOST_SWITCH is
  11005.  
  11006.         when LOAD => 
  11007.         READ (FILE_1, PT_TABLE, D_IO.POSITIVE_COUNT (INTERFACE_NB + 1));
  11008.  
  11009.         when STORE => 
  11010.         WRITE (FILE_1, PT_TABLE,
  11011.                D_IO.POSITIVE_COUNT (INTERFACE_NB + 1));
  11012.     end case;
  11013.  
  11014.     CLOSE (FILE_1);
  11015.  
  11016.     end RDWR_POINTER_TABLE;
  11017.  
  11018.     procedure RDWR_IN_PARAMETERS (LOST_SWITCH : LOST_SWITCH_TYPE;
  11019.                   ITEM_1      : in out IN_PARAMETERS) is
  11020.  
  11021. --************************************************************************
  11022. --**                                                                    **
  11023. --**   UNIT NAME :               RDWR_IN_PARAMETERS                     **
  11024. --**   ~~~~~~~~~~~                                                      **
  11025. --**                                                                    **
  11026. --************************************************************************
  11027.  
  11028.     package D_IO is new DIRECT_IO (IN_PARAMETERS);
  11029.     use D_IO;
  11030.  
  11031.     FILE_1 : D_IO.FILE_TYPE;
  11032.  
  11033.     begin
  11034.  
  11035.     D_IO.OPEN (FILE => FILE_1,
  11036.            MODE => D_IO.INOUT_FILE,
  11037.            NAME => "t_bed_in_p_" &
  11038.                INTERFACE_PROCEDURE_NAME'IMAGE
  11039.                  (INTERFACE_PROCEDURE_NAME'VAL (INTERFACE_NB)));
  11040.  
  11041.     case LOST_SWITCH is
  11042.  
  11043.         when LOAD => 
  11044.         READ (FILE_1, ITEM_1, D_IO.POSITIVE_COUNT (TEST_CASE_NB));
  11045.  
  11046.         when STORE => 
  11047.         WRITE (FILE_1, ITEM_1, D_IO.POSITIVE_COUNT (TEST_CASE_NB));
  11048.  
  11049.     end case;
  11050.  
  11051.     CLOSE (FILE_1);
  11052.  
  11053.     end RDWR_IN_PARAMETERS;
  11054.     procedure RDWR_OUT_PARAMETERS (LOST_SWITCH : LOST_SWITCH_TYPE;
  11055.                    ITEM_1      : in out OUT_PARAMETERS) is
  11056.  
  11057. --************************************************************************
  11058. --**                                                                    **
  11059. --**   UNIT NAME :               RDWR_OUT_PARAMETERS                    **
  11060. --**   ~~~~~~~~~~~                                                      **
  11061. --**                                                                    **
  11062. --************************************************************************
  11063.  
  11064.     package D_IO is new DIRECT_IO (OUT_PARAMETERS);
  11065.     use D_IO;
  11066.  
  11067.     FILE_1                 : D_IO.FILE_TYPE;
  11068.     OUT_PARAMETERS_ADDRESS : D_IO.POSITIVE_COUNT;
  11069.  
  11070.     begin
  11071.  
  11072.     D_IO.OPEN (FILE => FILE_1,
  11073.            MODE => D_IO.INOUT_FILE,
  11074.            NAME => "t_bed_out_p_" &
  11075.                ACCESS_PROCEDURE_NAME'IMAGE
  11076.                  (ACCESS_PROCEDURE_NAME'VAL (ACCESS_NB)));
  11077.  
  11078.     OUT_PARAMETERS_ADDRESS :=
  11079.       D_IO.POSITIVE_COUNT (ARR'LENGTH * INTERFACE_NB + TEST_CASE_NB);
  11080.  
  11081.     case LOST_SWITCH is
  11082.  
  11083.         when LOAD => 
  11084.         READ (FILE_1, ITEM_1, OUT_PARAMETERS_ADDRESS);
  11085.  
  11086.         when STORE => 
  11087.         WRITE (FILE_1, ITEM_1, OUT_PARAMETERS_ADDRESS);
  11088.  
  11089.     end case;
  11090.  
  11091.     CLOSE (FILE_1);
  11092.  
  11093.     end RDWR_OUT_PARAMETERS;
  11094.     procedure RDWR_TABLE_DESCRIPTORS (LOST_SWITCH : LOST_SWITCH_TYPE) is
  11095.  
  11096. --************************************************************************
  11097. --**                                                                    **
  11098. --**   UNIT NAME :               RDWR_TABLE_DESCRIPTORS                 **
  11099. --**   ~~~~~~~~~~~                                                      **
  11100. --************************************************************************
  11101.  
  11102.     package D_IO is new DIRECT_IO (TABLE_DESCRIPTORX);
  11103.     use D_IO;
  11104.  
  11105.     FILE_1                    : D_IO.FILE_TYPE;
  11106.     TABLE_DESCRIPTORS_ADDRESS : D_IO.POSITIVE_COUNT;
  11107.     CURRENT                   : ENUM_ITEM_ACCESS;
  11108.     K                         : INTEGER;
  11109.     TB_DESCRIPTORS            : TABLE_DESCRIPTORX;
  11110.  
  11111.     begin
  11112.     OPEN (FILE => FILE_1,
  11113.           MODE => D_IO.INOUT_FILE,
  11114.           NAME => "t_bed_table_descriptors");
  11115.  
  11116.     TABLE_DESCRIPTORS_ADDRESS :=
  11117.       D_IO.POSITIVE_COUNT (ARR'LENGTH * INTERFACE_NB + TEST_CASE_NB);
  11118.  
  11119.     case LOST_SWITCH is
  11120.  
  11121.         when LOAD => 
  11122.         READ (FILE_1, TB_DESCRIPTORS, TABLE_DESCRIPTORS_ADDRESS);
  11123.  
  11124.         -- GET_DESCRIPTOR must be used in order to fill the
  11125.         -- TABLE_DESCRIPTOR package when a TABLE_DESCRIPTORS
  11126.         -- record has been read from the corresponding file.
  11127.  
  11128.         SHARE.A_DATABASE_IS_OPEN := TB_DESCRIPTORS.A_DATABASE_IS_OPEN;
  11129.         SHARE.OPEN_DATABASE_NAME := TB_DESCRIPTORS.OPEN_DATABASE_NAME;
  11130.  
  11131.         DAMES_STATUS.EMBEDDED_INTERFACE_IS_IN_USE :=
  11132.           TB_DESCRIPTORS.EMBEDDED_INTERFACE_IS_IN_USE;
  11133.  
  11134.         TABLE := TB_DESCRIPTORS.MAIN;
  11135.  
  11136.         for I in 1 .. TABLE_NO loop
  11137.             if TABLE (I).TABLE_STATUS.SELECTION_CRITERION /= null then
  11138.             TABLE (I).TABLE_STATUS.SELECTION_CRITERION := new NODE;
  11139.             TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all :=
  11140.               TB_DESCRIPTORS.SELECTION_CRITERION (I);
  11141.             end if;
  11142.         end loop;
  11143.  
  11144.         for I in 1 .. TABLE_NO loop
  11145.             for J in 1 .. COL_NO loop
  11146.             if TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J) /=
  11147.                null then
  11148.                 TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J) :=
  11149.                   new STRING (1 .. 2 * RANGE_SIZE);
  11150.                 TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J).all :=
  11151.                   TB_DESCRIPTORS.CONSTRAINTS (I, J);
  11152.             end if;
  11153.             end loop;
  11154.         end loop;
  11155.         for I in 1 .. TABLE_NO loop
  11156.             for J in 1 .. COL_NO loop
  11157.             TABLE (I).TABLE_DEFINITION.ENUM_TYPES (J) := null;
  11158.  
  11159.             for K in 1 .. MAX_ENUM loop
  11160.                 exit when TB_DESCRIPTORS.ENUM_TYPES (I, J, K) =
  11161.                       (1 .. IMAGE_SZ => ' ');
  11162.                 if K = 1 then
  11163.                 CURRENT := new ENUM_ITEM;
  11164.                 TABLE (I).TABLE_DEFINITION.ENUM_TYPES (J) :=
  11165.                   CURRENT;
  11166.                 else
  11167.                 CURRENT.all.OTHER := new ENUM_ITEM;
  11168.                 CURRENT := CURRENT.all.OTHER;
  11169.                 end if;
  11170.                 CURRENT.all.ENUM_IMAGE :=
  11171.                   TB_DESCRIPTORS.ENUM_TYPES (I, J, K);
  11172.             end loop;
  11173.             end loop;
  11174.         end loop;
  11175.  
  11176.         when STORE => 
  11177.  
  11178. -- PUT_DESCRIPTOR must be used in order to fill a
  11179. -- TABLE_DESCRIPTORS record to be written into the
  11180. -- associated file.
  11181.  
  11182.         TB_DESCRIPTORS.A_DATABASE_IS_OPEN := SHARE.A_DATABASE_IS_OPEN;
  11183.         TB_DESCRIPTORS.OPEN_DATABASE_NAME := SHARE.OPEN_DATABASE_NAME;
  11184.  
  11185.         TB_DESCRIPTORS.EMBEDDED_INTERFACE_IS_IN_USE :=
  11186.           DAMES_STATUS.EMBEDDED_INTERFACE_IS_IN_USE;
  11187.  
  11188.         TB_DESCRIPTORS.MAIN := TABLE;
  11189.  
  11190.         for I in 1 .. TABLE_NO loop
  11191.             if TABLE (I).TABLE_STATUS.SELECTION_CRITERION /= null then
  11192.             TB_DESCRIPTORS.SELECTION_CRITERION (I) :=
  11193.               TABLE (I).TABLE_STATUS.SELECTION_CRITERION.all;
  11194.             end if;
  11195.         end loop;
  11196.  
  11197.         for I in 1 .. TABLE_NO loop
  11198.             for J in 1 .. COL_NO loop
  11199.             if TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J) /=
  11200.                null then
  11201.                 TB_DESCRIPTORS.CONSTRAINTS (I, J) :=
  11202.                   TABLE (I).TABLE_DEFINITION.CONSTRAINTS (J).all;
  11203.             end if;
  11204.             end loop;
  11205.         end loop;
  11206.  
  11207.         for I in 1 .. TABLE_NO loop
  11208.             for J in 1 .. COL_NO loop
  11209.             CURRENT := TABLE (I).TABLE_DEFINITION.ENUM_TYPES (J);
  11210.             K := 1;
  11211.  
  11212.             while CURRENT /= null loop
  11213.                 TB_DESCRIPTORS.ENUM_TYPES (I, J, K) :=
  11214.                   CURRENT.all.ENUM_IMAGE;
  11215.                 K := K + 1;
  11216.                 CURRENT := CURRENT.all.OTHER;
  11217.                 exit when K = MAX_ENUM + 1;
  11218.             end loop;
  11219.             end loop;
  11220.         end loop;
  11221.  
  11222.         WRITE (FILE_1, TB_DESCRIPTORS, TABLE_DESCRIPTORS_ADDRESS);
  11223.     end case;
  11224.  
  11225.     CLOSE (FILE_1);
  11226.  
  11227.     end RDWR_TABLE_DESCRIPTORS;
  11228.     procedure EXECUTE_ONE_TEST_CASE is
  11229.  
  11230. --************************************************************************
  11231. --**                                                                    **
  11232. --**   UNIT NAME :               EXECUTE_ONE_TEST_CASE                  **
  11233. --**   ~~~~~~~~~~~                                                      **
  11234. --************************************************************************
  11235.  
  11236.     FLOAT_STR : STRING (1 .. 15);
  11237.  
  11238.     begin
  11239.     IN_PARAMETERS (READ);
  11240.     RDWR_TABLE_DESCRIPTORS (LOAD);
  11241.  
  11242.     if not AUTOMATIC_VERSION then
  11243.         if IN_PARAMETER_IS_OPEN (INTERFACE_NB) then
  11244.         IN_PARAMETERS (PUT);
  11245.         if MODIFY then
  11246.             IN_PARAMETERS (GET);
  11247.         end if;
  11248.         end if;
  11249.         UPDATE_STATUS;
  11250.         NEW_PAGE;
  11251.     end if;
  11252.  
  11253.     SET_OUTPUT (LOG_FILE);
  11254.     NEW_PAGE;
  11255.     PUT ("***********************************************************************");
  11256.     NEW_LINE;
  11257.     PUT ("DATE :");
  11258.     PUT (INTEGER'IMAGE (YEAR (CLOCK)) & "/" &
  11259.          INTEGER'IMAGE (MONTH (CLOCK)) & "/" & INTEGER'IMAGE (DAY (CLOCK)));
  11260.     PUT ("  interface procedure " &
  11261.          INTERFACE_PROCEDURE_NAME'IMAGE (INTERFACE_PR_NAME));
  11262.     PUT ("  test case " & PT_TABLE.TEST_CASE (TEST_CASE_NB).NAME);
  11263.     NEW_LINE;
  11264.     PUT ("***********************************************************************");
  11265.     NEW_LINE (4);
  11266.     PUT ("------------ INTERFACE PROCEDURE IN_PARAMETERS ---------------");
  11267.     DISPLAY_SWITCH := LIST;
  11268.     IN_PARAMETERS (PUT);
  11269.     NEW_LINE (4);
  11270.     PUT ("------------ TABLE DESCRIPTORS -------------------------------");
  11271.     UPDATE_STATUS;
  11272.     DISPLAY_SWITCH := MODIFY;
  11273.     SET_OUTPUT (STANDARD_OUTPUT);
  11274.  
  11275. -------------------------------------------------------------------------------
  11276. --  Execute the interface procedure.
  11277. -------------------------------------------------------------------------------
  11278.     declare
  11279.         OH : constant STRING := "Exception raised : ";
  11280.     begin
  11281.  
  11282.         case INTERFACE_NB is
  11283.  
  11284.         when 00 =>  DAMES.OPEN (IN_PARAMETERS_00.DB_NAME);
  11285.  
  11286.         when 01 =>  DAMES.EXECUTE (IN_PARAMETERS_01.COMMAND);
  11287.  
  11288.         when 02 =>  DAMES.CLOSE;
  11289.  
  11290.         when 03 =>  LL_DAMES.OPEN (IN_PARAMETERS_00.DB_NAME);
  11291.  
  11292.         when 04 =>  LL_DAMES.DEFINE_TABLE
  11293.                    (IN_PARAMETERS_04.TABLE_NAME,
  11294.                 IN_PARAMETERS_04.COLUMN_LIST);
  11295.  
  11296.         when 05 =>  LL_DAMES.LOCK
  11297.                    (IN_PARAMETERS_05.LOCK_LIST
  11298.                    (1 .. IN_PARAMETERS_05.LLL));
  11299.  
  11300.         when 06 => 
  11301.             LL_DAMES.GET_INFORMATION
  11302.                (IN_PARAMETERS_06.TABLE_NAME, COLUMN_NUMBER,
  11303.             COLUMN_LIST);
  11304.             PRINT ("COLUMN_NUMBER := " &
  11305.                POSITIVE'IMAGE (COLUMN_NUMBER) & ASCII.LF &
  11306.                "COLUMN_LIST   := " & COLUMN_LIST);
  11307.  
  11308.         when 07 =>  LL_DAMES.UNLOCK;
  11309.  
  11310.         when 08 =>  LL_DAMES.CLOSE;
  11311.  
  11312.         when 09 => 
  11313.             E_MATCH (IN_PARAMETERS_09.TABLE_NAME,
  11314.                  IN_PARAMETERS_09.COLUMN_NAME,
  11315.                  IN_PARAMETERS_09.KEY_MATCH,
  11316.                  IN_PARAMETERS_09.COLUMN_VALUE.ENU);
  11317.  
  11318.         when 10 => 
  11319.             F_MATCH (IN_PARAMETERS_09.TABLE_NAME,
  11320.                  IN_PARAMETERS_09.COLUMN_NAME,
  11321.                  IN_PARAMETERS_09.KEY_MATCH,
  11322.                  IN_PARAMETERS_09.COLUMN_VALUE.FLO);
  11323.  
  11324.         when 11 => 
  11325.             I_MATCH (IN_PARAMETERS_09.TABLE_NAME,
  11326.                  IN_PARAMETERS_09.COLUMN_NAME,
  11327.                  IN_PARAMETERS_09.KEY_MATCH,
  11328.                  IN_PARAMETERS_09.COLUMN_VALUE.INT);
  11329.  
  11330.         when 12 => 
  11331.             R_MATCH (IN_PARAMETERS_09.TABLE_NAME,
  11332.                  IN_PARAMETERS_09.COLUMN_NAME,
  11333.                  IN_PARAMETERS_09.KEY_MATCH,
  11334.                  IN_PARAMETERS_09.COLUMN_VALUE);
  11335.         when 13 => 
  11336.             S_MATCH (IN_PARAMETERS_09.TABLE_NAME,
  11337.                  IN_PARAMETERS_09.COLUMN_NAME,
  11338.                  IN_PARAMETERS_09.KEY_MATCH,
  11339.                  IN_PARAMETERS_09.COLUMN_VALUE.STR);
  11340.  
  11341.         when 14 => 
  11342.             E_OR_MATCH
  11343.                (IN_PARAMETERS_09.TABLE_NAME,
  11344.             IN_PARAMETERS_09.COLUMN_NAME,
  11345.             IN_PARAMETERS_09.KEY_MATCH,
  11346.             IN_PARAMETERS_09.COLUMN_VALUE.ENU);
  11347.  
  11348.         when 15 => 
  11349.             F_OR_MATCH
  11350.                (IN_PARAMETERS_09.TABLE_NAME,
  11351.             IN_PARAMETERS_09.COLUMN_NAME,
  11352.             IN_PARAMETERS_09.KEY_MATCH,
  11353.             IN_PARAMETERS_09.COLUMN_VALUE.FLO);
  11354.  
  11355.         when 16 => 
  11356.             I_OR_MATCH
  11357.                (IN_PARAMETERS_09.TABLE_NAME,
  11358.             IN_PARAMETERS_09.COLUMN_NAME,
  11359.             IN_PARAMETERS_09.KEY_MATCH,
  11360.             IN_PARAMETERS_09.COLUMN_VALUE.INT);
  11361.  
  11362.         when 17 => 
  11363.             R_OR_MATCH
  11364.                (IN_PARAMETERS_09.TABLE_NAME,
  11365.             IN_PARAMETERS_09.COLUMN_NAME,
  11366.             IN_PARAMETERS_09.KEY_MATCH,
  11367.             IN_PARAMETERS_09.COLUMN_VALUE);
  11368.  
  11369.         when 18 => 
  11370.             S_OR_MATCH
  11371.                (IN_PARAMETERS_09.TABLE_NAME,
  11372.             IN_PARAMETERS_09.COLUMN_NAME,
  11373.             IN_PARAMETERS_09.KEY_MATCH,
  11374.             IN_PARAMETERS_09.COLUMN_VALUE.STR);
  11375.  
  11376.         when 19 => 
  11377.             E_AND_MATCH
  11378.                (IN_PARAMETERS_09.TABLE_NAME,
  11379.             IN_PARAMETERS_09.COLUMN_NAME,
  11380.             IN_PARAMETERS_09.KEY_MATCH,
  11381.             IN_PARAMETERS_09.COLUMN_VALUE.ENU);
  11382.  
  11383.         when 20 => 
  11384.             F_AND_MATCH
  11385.                (IN_PARAMETERS_09.TABLE_NAME,
  11386.             IN_PARAMETERS_09.COLUMN_NAME,
  11387.             IN_PARAMETERS_09.KEY_MATCH,
  11388.             IN_PARAMETERS_09.COLUMN_VALUE.FLO);
  11389.         when 21 => 
  11390.             I_AND_MATCH
  11391.                (IN_PARAMETERS_09.TABLE_NAME,
  11392.             IN_PARAMETERS_09.COLUMN_NAME,
  11393.             IN_PARAMETERS_09.KEY_MATCH,
  11394.             IN_PARAMETERS_09.COLUMN_VALUE.INT);
  11395.  
  11396.         when 22 => 
  11397.             R_AND_MATCH
  11398.                (IN_PARAMETERS_09.TABLE_NAME,
  11399.             IN_PARAMETERS_09.COLUMN_NAME,
  11400.             IN_PARAMETERS_09.KEY_MATCH,
  11401.             IN_PARAMETERS_09.COLUMN_VALUE);
  11402.  
  11403.         when 23 => 
  11404.             S_AND_MATCH
  11405.                (IN_PARAMETERS_09.TABLE_NAME,
  11406.             IN_PARAMETERS_09.COLUMN_NAME,
  11407.             IN_PARAMETERS_09.KEY_MATCH,
  11408.             IN_PARAMETERS_09.COLUMN_VALUE.STR);
  11409.  
  11410.         when 24 =>  LL_DAMES.FIND (IN_PARAMETERS_06.TABLE_NAME);
  11411.  
  11412.         when 25 => 
  11413.             FIND_NEXT_RETURN :=
  11414.               LL_DAMES.FIND_NEXT (IN_PARAMETERS_06.TABLE_NAME);
  11415.             PRINT ("FIND_NEXT_RETURN := " &
  11416.                BOOLEAN'IMAGE (FIND_NEXT_RETURN));
  11417.  
  11418.         when 26 => 
  11419.             FIND_PREVIOUS_RETURN :=
  11420.               LL_DAMES.FIND_PREVIOUS (IN_PARAMETERS_06.TABLE_NAME);
  11421.             PRINT ("FIND_PREVIOUS_RETURN := " &
  11422.                BOOLEAN'IMAGE (FIND_PREVIOUS_RETURN));
  11423.  
  11424.         when 27 => 
  11425.             NEXT_RETURN := LL_DAMES.NEXT (IN_PARAMETERS_06.TABLE_NAME);
  11426.             PRINT ("NEXT_RETURN := " & BOOLEAN'IMAGE (NEXT_RETURN));
  11427.  
  11428.         when 28 => 
  11429.             PREVIOUS_RETURN :=
  11430.               LL_DAMES.PREVIOUS (IN_PARAMETERS_06.TABLE_NAME);
  11431.             PRINT ("PREVIOUS_RETURN := " &
  11432.                BOOLEAN'IMAGE (PREVIOUS_RETURN));
  11433.  
  11434.         when 29 => 
  11435.             E_GET_COLUMN
  11436.                (IN_PARAMETERS_17.TABLE_NAME,
  11437.             IN_PARAMETERS_17.COLUMN_NAME, ITEM.ENU);
  11438.             PRINT ("ITEM.ENU := " & ENUM'IMAGE (ITEM.ENU));
  11439.  
  11440.         when 30 => 
  11441.             F_GET_COLUMN
  11442.                (IN_PARAMETERS_17.TABLE_NAME,
  11443.             IN_PARAMETERS_17.COLUMN_NAME, ITEM.FLO);
  11444.             F.PUT (FLOAT_STR, ITEM.FLO);
  11445.             PRINT ("ITEM.FLO := " & FLOAT_STR);
  11446.         when 31 => 
  11447.             I_GET_COLUMN
  11448.                (IN_PARAMETERS_17.TABLE_NAME,
  11449.             IN_PARAMETERS_17.COLUMN_NAME, ITEM.INT);
  11450.             PRINT ("ITEM.INT := " & INTEGER'IMAGE (ITEM.INT));
  11451.  
  11452.         when 32 => 
  11453.             R_GET_COLUMN
  11454.                (IN_PARAMETERS_17.TABLE_NAME,
  11455.             IN_PARAMETERS_17.COLUMN_NAME, ITEM);
  11456.             F.PUT (FLOAT_STR, ITEM.FLO);
  11457.             PRINT ("ITEM.ENU := " & ENUM'IMAGE (ITEM.ENU) & ASCII.LF &
  11458.                "ITEM.INT := " & INTEGER'IMAGE (ITEM.INT) &
  11459.                ASCII.LF & "ITEM.STR := " & ITEM.STR & ASCII.LF &
  11460.                "ITEM.FLO := " & FLOAT_STR);
  11461.  
  11462.         when 33 => 
  11463.             S_GET_COLUMN
  11464.                (IN_PARAMETERS_17.TABLE_NAME,
  11465.             IN_PARAMETERS_17.COLUMN_NAME, ITEM.STR);
  11466.             PRINT ("ITEM.STR := " & ITEM.STR);
  11467.  
  11468.         when 34 => 
  11469.             E_GET_ROW (IN_PARAMETERS_06.TABLE_NAME, ITEM.ENU);
  11470.             PRINT ("ITEM.ENU := " & ENUM'IMAGE (ITEM.ENU));
  11471.  
  11472.         when 35 => 
  11473.             F_GET_ROW (IN_PARAMETERS_06.TABLE_NAME, ITEM.FLO);
  11474.             F.PUT (FLOAT_STR, ITEM.FLO);
  11475.             PRINT ("ITEM.FLO := " & FLOAT_STR);
  11476.  
  11477.         when 36 => 
  11478.             I_GET_ROW (IN_PARAMETERS_06.TABLE_NAME, ITEM.INT);
  11479.             PRINT ("ITEM.INT := " & INTEGER'IMAGE (ITEM.INT));
  11480.  
  11481.         when 37 => 
  11482.             R_GET_ROW (IN_PARAMETERS_06.TABLE_NAME, ITEM);
  11483.             F.PUT (FLOAT_STR, ITEM.FLO);
  11484.             PRINT ("ITEM.ENU := " & ENUM'IMAGE (ITEM.ENU) & ASCII.LF &
  11485.                "ITEM.INT := " & INTEGER'IMAGE (ITEM.INT) &
  11486.                ASCII.LF & "ITEM.STR := " & ITEM.STR & ASCII.LF &
  11487.                "ITEM.FLO := " & FLOAT_STR);
  11488.  
  11489.         when 38 => 
  11490.             S_GET_ROW (IN_PARAMETERS_06.TABLE_NAME, ITEM.STR);
  11491.             PRINT ("ITEM.STR := " & ITEM.STR);
  11492.  
  11493.         when 39 => 
  11494.             E_BUILD_COLUMN
  11495.                (IN_PARAMETERS_19.TABLE_NAME,
  11496.             IN_PARAMETERS_19.COLUMN_NAME,
  11497.             IN_PARAMETERS_19.ITEM.ENU);
  11498.  
  11499.         when 40 => 
  11500.             F_BUILD_COLUMN
  11501.                (IN_PARAMETERS_19.TABLE_NAME,
  11502.             IN_PARAMETERS_19.COLUMN_NAME,
  11503.             IN_PARAMETERS_19.ITEM.FLO);
  11504.         when 41 => 
  11505.             I_BUILD_COLUMN
  11506.                (IN_PARAMETERS_19.TABLE_NAME,
  11507.             IN_PARAMETERS_19.COLUMN_NAME,
  11508.             IN_PARAMETERS_19.ITEM.INT);
  11509.  
  11510.         when 42 => 
  11511.             R_BUILD_COLUMN
  11512.                (IN_PARAMETERS_19.TABLE_NAME,
  11513.             IN_PARAMETERS_19.COLUMN_NAME, IN_PARAMETERS_19.ITEM);
  11514.  
  11515.         when 43 => 
  11516.             S_BUILD_COLUMN
  11517.                (IN_PARAMETERS_19.TABLE_NAME,
  11518.             IN_PARAMETERS_19.COLUMN_NAME,
  11519.             IN_PARAMETERS_19.ITEM.STR);
  11520.  
  11521.         when 44 => 
  11522.             E_BUILD_ROW
  11523.                (IN_PARAMETERS_20.TABLE_NAME, IN_PARAMETERS_20.ITM.ENU);
  11524.  
  11525.         when 45 => 
  11526.             F_BUILD_ROW
  11527.                (IN_PARAMETERS_20.TABLE_NAME, IN_PARAMETERS_20.ITM.FLO);
  11528.  
  11529.         when 46 => 
  11530.             I_BUILD_ROW
  11531.                (IN_PARAMETERS_20.TABLE_NAME, IN_PARAMETERS_20.ITM.INT);
  11532.  
  11533.         when 47 => 
  11534.             R_BUILD_ROW
  11535.                (IN_PARAMETERS_20.TABLE_NAME, IN_PARAMETERS_20.ITM);
  11536.  
  11537.         when 48 => 
  11538.             S_BUILD_ROW
  11539.                (IN_PARAMETERS_20.TABLE_NAME, IN_PARAMETERS_20.ITM.STR);
  11540.  
  11541.         when 49 =>  LL_DAMES.UPDATE (IN_PARAMETERS_06.TABLE_NAME);
  11542.  
  11543.         when 50 =>  LL_DAMES.INSERT (IN_PARAMETERS_06.TABLE_NAME);
  11544.  
  11545.         when 51 => 
  11546.             LL_DAMES.DELETE (IN_PARAMETERS_06.TABLE_NAME, NO_MORE_ROW);
  11547.             PRINT ("NO_MORE_ROW :=" & BOOLEAN'IMAGE (NO_MORE_ROW));
  11548.  
  11549.         when others =>  null;
  11550.         end case;
  11551. -------------------------------------------------------------------------------
  11552. --  Store the raised exceptions  of the interface procedure                  --
  11553. -------------------------------------------------------------------------------
  11554.     exception
  11555.  
  11556. -- This exceptions is raised in DAMES subprograms when errors occur in.
  11557.  
  11558.         when X_DAMES_ERROR =>  PRINT (OH & " X_DAMES_ERROR ");
  11559.  
  11560. -- These exceptions are raised in the LL_DAMES subprograms 
  11561. -- when errors occur in.
  11562.  
  11563.         when X_CANT_ACCESS_DB =>  PRINT (OH & " X_CANT_ACCESS_DB ");
  11564.         when X_CANT_ACCESS_TABLE =>  PRINT (OH & " X_CANT_ACCESS_TABLE ");
  11565.         when X_FULL_TABLE =>  PRINT (OH & " X_FULL_TABLE ");
  11566.         when X_INTERNAL_ERROR =>  PRINT (OH & " X_INTERNAL_ERROR ");
  11567.         when X_INVALID_COLUMN =>  PRINT (OH & " X_INVALID_COLUMN ");
  11568.         when X_INVALID_CRITERION =>  PRINT (OH & " X_INVALID_CRITERION ");
  11569.         when X_INVALID_VALUE =>  PRINT (OH & " X_INVALID_VALUE ");
  11570.         when X_NO_CURRENT_ROW =>  PRINT (OH & " X_NO_CURRENT_ROW ");
  11571.         when X_NO_MORE_ROWS =>  PRINT (OH & " X_NO_MORE_ROWS ");
  11572.         when X_NO_OPEN_DB =>  PRINT (OH & " X_NO_OPEN_DB ");
  11573.         when X_NO_PREVIOUS_FIND =>  PRINT (OH & " X_NO_PREVIOUS_FIND ");
  11574.         when X_NO_PREVIOUS_MATCH =>  PRINT (OH & " X_NO_PREVIOUS_MATCH ");
  11575.         when X_OPEN_DB =>  PRINT (OH & " X_OPEN_DB ");
  11576.         when X_SHARED_MODE_LOCK =>  PRINT (OH & " X_SHARED_MODE_LOCK ");
  11577.         when X_TABLE_NOT_LOCKED =>  PRINT (OH & " X_TABLE_NOT_LOCKED ");
  11578.         when X_TOO_SHORT_STRING =>  PRINT (OH & " X_TOO_SHORT_STRING ");
  11579.  
  11580. -- these are the predefined exceptions.
  11581.  
  11582.         when CONSTRAINT_ERROR =>  PRINT (OH & " CONSTRAINT_ERROR ");
  11583.         when NUMERIC_ERROR =>  PRINT (OH & " NUMERIC_ERROR ");
  11584.         when PROGRAM_ERROR =>  PRINT (OH & " PROGRAM_ERROR ");
  11585.         when STORAGE_ERROR =>  PRINT (OH & " STORAGE_ERROR ");
  11586.         when TASKING_ERROR =>  PRINT (OH & " TASKING_ERROR ");
  11587.         when others =>  PRINT (OH & " OTHERS ");
  11588.     end;
  11589.     if not AUTOMATIC_VERSION then
  11590.         SET_OUTPUT (STANDARD_OUTPUT);
  11591.         NEW_PAGE;
  11592.         PUT (TEST_BED_FUNCTION'IMAGE (T_B_FUNCTION) &
  11593.          " interface procedure " &
  11594.          INTERFACE_PROCEDURE_NAME'IMAGE (INTERFACE_PR_NAME));
  11595.         NEW_LINE (8);
  11596.         PUT ("TEST CASE " & PT_TABLE.TEST_CASE (TEST_CASE_NB).NAME &
  11597.          " terminated ");
  11598.         DISPL (0, 23, "Do you want to read the table_descriptors (y/n) ? ");
  11599.         loop
  11600.         SCREEN_POS (50, 23);  GET (A);
  11601.         exit when A = 'y' or A = 'n';
  11602.         end loop;
  11603.         if A = 'y' then
  11604.         DISPLAY_SWITCH := READ;
  11605.         UPDATE_STATUS;
  11606.         DISPLAY_SWITCH := MODIFY;
  11607.         end if;
  11608.     end if;
  11609.  
  11610.     SET_OUTPUT (LOG_FILE);
  11611.     NEW_LINE (4);
  11612.     PUT ("------------ TABLE DESCRIPTORS -------------------------------");
  11613.     DISPLAY_SWITCH := LIST;
  11614.     UPDATE_STATUS;
  11615.     DISPLAY_SWITCH := MODIFY;
  11616.     SET_OUTPUT (STANDARD_OUTPUT);
  11617.  
  11618.     end EXECUTE_ONE_TEST_CASE;
  11619.     procedure IN_PARAMETERS (RPGW_SWITCH : RPGW_SWITCH_TYPE) is
  11620.  
  11621. --************************************************************************
  11622. --**                                                                    **
  11623. --**   UNIT NAME :               IN_PARAMETERS                          **
  11624. --**   ~~~~~~~~~~~                                                      **
  11625. --************************************************************************
  11626.  
  11627.     procedure RDWR_IN_PARAMETERS_00 is new RDWR_IN_PARAMETERS
  11628.            (IN_PARAMETER_00);
  11629.     procedure RDWR_IN_PARAMETERS_01 is new RDWR_IN_PARAMETERS
  11630.            (IN_PARAMETER_01);
  11631.     procedure RDWR_IN_PARAMETERS_04 is new RDWR_IN_PARAMETERS
  11632.            (IN_PARAMETER_04);
  11633.     procedure RDWR_IN_PARAMETERS_05 is new RDWR_IN_PARAMETERS
  11634.            (IN_PARAMETER_05);
  11635.     procedure RDWR_IN_PARAMETERS_06 is new RDWR_IN_PARAMETERS
  11636.            (IN_PARAMETER_06);
  11637.     procedure RDWR_IN_PARAMETERS_09 is new RDWR_IN_PARAMETERS
  11638.            (IN_PARAMETER_09);
  11639.     procedure RDWR_IN_PARAMETERS_17 is new RDWR_IN_PARAMETERS
  11640.            (IN_PARAMETER_17);
  11641.     procedure RDWR_IN_PARAMETERS_19 is new RDWR_IN_PARAMETERS
  11642.            (IN_PARAMETER_19);
  11643.     procedure RDWR_IN_PARAMETERS_20 is new RDWR_IN_PARAMETERS
  11644.            (IN_PARAMETER_20);
  11645.  
  11646.     LOST_SWITCH : LOST_SWITCH_TYPE;
  11647.  
  11648. -------------------------------------------------------------------------------
  11649.     procedure PUT (C : COLUMN_TYPE; RCD : RECD) is
  11650.     begin
  11651.         case INTERFACE_NB is
  11652.         when 9 | 14 | 19 | 29 | 34 | 39 | 44 => 
  11653.             PUT_LINE (".ENU : " & ENUM'IMAGE (RCD.ENU));
  11654.         when 10 | 15 | 20 | 30 | 35 | 40 | 45 => 
  11655.             PUT (".FLO : ");  F.PUT (RCD.FLO);
  11656.             NEW_LINE;
  11657.         when 11 | 16 | 21 | 31 | 36 | 41 | 46 => 
  11658.             PUT_LINE (".INT : " & INTEGER'IMAGE (RCD.INT));
  11659.         when 12 | 17 | 22 | 32 | 37 | 42 | 47 => 
  11660.             PUT_LINE (".ENU : " & ENUM'IMAGE (RCD.ENU));
  11661.             SET_COL (POSITIVE_COUNT (C));
  11662.             PUT (".FLO : ");  F.PUT (RCD.FLO);
  11663.             NEW_LINE;
  11664.             SET_COL (POSITIVE_COUNT (C));
  11665.             PUT_LINE (".INT : " & INTEGER'IMAGE (RCD.INT));
  11666.             SET_COL (POSITIVE_COUNT (C));
  11667.             PUT_LINE (".STR : " & RCD.STR);
  11668.         when 13 | 18 | 23 | 33 | 38 | 43 | 48 => 
  11669.             PUT_LINE (".STR : " & RCD.STR);
  11670.         when others =>  null;
  11671.         end case;
  11672.     end PUT;
  11673. -------------------------------------------------------------------------------
  11674.     procedure GET (C : COLUMN_TYPE; R : ROW_TYPE; RCD : in out RECD) is
  11675.     begin
  11676.         SCREEN_POS (C, R);
  11677.         case INTERFACE_NB is
  11678.         when 9 | 14 | 19 | 29 | 34 | 39 | 44 => 
  11679.             GET_LINE (ENUM_STRING, LAST);
  11680.             if LAST /= 0 then
  11681.             RCD.ENU := ENUM'VALUE (ENUM_STRING (1 .. LAST));
  11682.             end if;
  11683.  
  11684.         when 10 | 15 | 20 | 30 | 35 | 40 | 45 => 
  11685.             F_GET (RCD.FLO);
  11686.         when 11 | 16 | 21 | 31 | 36 | 41 | 46 => 
  11687.             I_GET (RCD.INT);
  11688.         when 12 | 17 | 22 | 32 | 37 | 42 | 47 => 
  11689.             GET_LINE (ENUM_STRING, LAST);
  11690.             if LAST /= 0 then
  11691.             RCD.ENU := ENUM'VALUE (ENUM_STRING (1 .. LAST));
  11692.             end if;
  11693.             SCREEN_POS (C, R + 1);
  11694.             F_GET (RCD.FLO);
  11695.             SCREEN_POS (C, R + 2);
  11696.             I_GET (RCD.INT);
  11697.             SCREEN_POS (C, R + 3);
  11698.             GET (RCD.STR);
  11699.         when 13 | 18 | 23 | 33 | 38 | 43 | 48 => 
  11700.             GET (RCD.STR);
  11701.         when others =>  null;
  11702.         end case;
  11703.     end GET;
  11704. -------------------------------------------------------------------------------
  11705. --                            procedure body                                 --
  11706. -------------------------------------------------------------------------------
  11707.     begin
  11708.     PARAMETER := IN_PARAMETERS;
  11709.  
  11710.     case RPGW_SWITCH is
  11711.         when READ => 
  11712.         NEW_PAGE;
  11713.         LOST_SWITCH := LOAD;
  11714.         when WRITE => 
  11715.         NEW_PAGE;
  11716.         LOST_SWITCH := STORE;
  11717.         when PUT => 
  11718.         NEWPAGE;
  11719.         when GET =>  null;
  11720.     end case;
  11721.  
  11722.     case INTERFACE_NB is
  11723.         when 0 | 3 => 
  11724.         case RPGW_SWITCH is
  11725.             when PUT => 
  11726.             PUT_LINE ("DB_NAME : " & IN_PARAMETERS_00.DB_NAME);
  11727.             when GET => 
  11728.             SCREEN_POS (10, 3);
  11729.             GET (IN_PARAMETERS_00.DB_NAME);
  11730.             when others => 
  11731.             RDWR_IN_PARAMETERS_00 (LOST_SWITCH, IN_PARAMETERS_00);
  11732.         end case;
  11733.  
  11734.         when 1 => 
  11735.         case RPGW_SWITCH is
  11736.             when PUT => 
  11737.             PUT_LINE ("COMMAND : " & IN_PARAMETERS_01.COMMAND);
  11738.             when GET => 
  11739.             SCREEN_POS (10, 3);
  11740.             GET (IN_PARAMETERS_01.COMMAND);
  11741.             when others => 
  11742.             RDWR_IN_PARAMETERS_01 (LOST_SWITCH, IN_PARAMETERS_01);
  11743.         end case;
  11744.         when 2 | 7 | 8 => 
  11745.         null;
  11746.         when 5 => 
  11747.         case RPGW_SWITCH is
  11748.             when PUT => 
  11749.             PUT_LINE ("LLL := " &
  11750.                   INTEGER'IMAGE (IN_PARAMETERS_05.LLL));
  11751.             for I in 1 .. IN_PARAMETERS_05.LLL loop
  11752.                 PUT_LINE ("LOCK_LIST (" & INTEGER'IMAGE (I) &
  11753.                       ").TABLE_NAME : " &
  11754.                       IN_PARAMETERS_05.LOCK_LIST (I)
  11755.                        .TABLE_NAME);
  11756.                 PUT_LINE ("LOCK_LIST (" & INTEGER'IMAGE (I) &
  11757.                       ").ACCESS_MODE : " &
  11758.                       ACCESS_MODE_TYPE'IMAGE
  11759.                     (IN_PARAMETERS_05.LOCK_LIST (I)
  11760.                       .ACCESS_MODE));
  11761.             end loop;
  11762.             when GET => 
  11763.             SCREEN_POS (08, 3);
  11764.             I_GET (IN_PARAMETERS_05.LLL);
  11765.             for I in 1 .. IN_PARAMETERS_05.LLL loop
  11766.                 SCREEN_POS (28, 2 * I + 2);
  11767.                 GET (IN_PARAMETERS_05.LOCK_LIST (I).TABLE_NAME);
  11768.                 SCREEN_POS (29, 2 * I + 3);
  11769.                 GET_LINE (ENUM_STRING, LAST);
  11770.                 if LAST /= 0 then
  11771.                 IN_PARAMETERS_05.LOCK_LIST (I).ACCESS_MODE :=
  11772.                   ACCESS_MODE_TYPE'VALUE
  11773.                     (ENUM_STRING (1 .. LAST));
  11774.                 end if;
  11775.             end loop;
  11776.             when others => 
  11777.             RDWR_IN_PARAMETERS_05 (LOST_SWITCH, IN_PARAMETERS_05);
  11778.         end case;
  11779.  
  11780.         when others => 
  11781.         case INTERFACE_NB is
  11782.             when 4 => 
  11783.             case RPGW_SWITCH is
  11784.                 when PUT => 
  11785.                 PUT_LINE ("TABLE_NAME : " &
  11786.                       IN_PARAMETERS_04.TABLE_NAME);
  11787.                 PUT_LINE ("COLUMN_LIST : " &
  11788.                       IN_PARAMETERS_04.COLUMN_LIST);
  11789.                 when GET => 
  11790.                 SCREEN_POS (13, 3);
  11791.                 GET (IN_PARAMETERS_04.TABLE_NAME);
  11792.                 SCREEN_POS (14, 4);
  11793.                 GET (IN_PARAMETERS_04.COLUMN_LIST);
  11794.                 when others => 
  11795.                 RDWR_IN_PARAMETERS_04
  11796.                    (LOST_SWITCH, IN_PARAMETERS_04);
  11797.             end case;
  11798.             when 44 .. 48 => 
  11799.             case RPGW_SWITCH is
  11800.                 when PUT => 
  11801.                 PUT_LINE ("TABLE_NAME : " &
  11802.                       IN_PARAMETERS_20.TABLE_NAME);
  11803.                 PUT ("ITM");  PUT (4, IN_PARAMETERS_20.ITM);
  11804.                 when GET => 
  11805.                 SCREEN_POS (13, 3);
  11806.                 GET (IN_PARAMETERS_20.TABLE_NAME);
  11807.                 GET (9, 4, IN_PARAMETERS_20.ITM);
  11808.                 when others => 
  11809.                 RDWR_IN_PARAMETERS_20
  11810.                    (LOST_SWITCH, IN_PARAMETERS_20);
  11811.             end case;
  11812.  
  11813.             when 09 .. 23 | 29 .. 33 | 39 .. 43 => 
  11814.             case INTERFACE_NB is
  11815.                 when 09 .. 23 => 
  11816.                 case RPGW_SWITCH is
  11817.                     when PUT => 
  11818.                     PUT_LINE ("TABLE_NAME : " &
  11819.                           IN_PARAMETERS_09.TABLE_NAME);
  11820.                     PUT_LINE ("COLUMN_NAME : " &
  11821.                           IN_PARAMETERS_09.COLUMN_NAME);
  11822.                     PUT_LINE ("KEY_MATCH : " &
  11823.                           KEY_MATCH_TYPE'IMAGE
  11824.                             (IN_PARAMETERS_09
  11825.                               .KEY_MATCH));
  11826.                     PUT ("COLUMN_VALUE");
  11827.                     PUT (13, IN_PARAMETERS_09.COLUMN_VALUE);
  11828.                     when GET => 
  11829.                     SCREEN_POS (13, 3);
  11830.                     GET (IN_PARAMETERS_09.TABLE_NAME);
  11831.                     SCREEN_POS (14, 4);
  11832.                     GET (IN_PARAMETERS_09.COLUMN_NAME);
  11833.                     SCREEN_POS (12, 5);
  11834.                     GET_LINE (ENUM_STRING, LAST);
  11835.                     if LAST /= 0 then
  11836.                         IN_PARAMETERS_09.KEY_MATCH :=
  11837.                           KEY_MATCH_TYPE'VALUE
  11838.                         (ENUM_STRING (1 .. LAST));
  11839.                     end if;
  11840.                     GET (19, 6,
  11841.                          IN_PARAMETERS_09.COLUMN_VALUE);
  11842.                     when others => 
  11843.                     RDWR_IN_PARAMETERS_09
  11844.                        (LOST_SWITCH, IN_PARAMETERS_09);
  11845.                 end case;
  11846.                 when 39 .. 43 => 
  11847.                 case RPGW_SWITCH is
  11848.                     when PUT => 
  11849.                     PUT_LINE ("TABLE_NAME : " &
  11850.                           IN_PARAMETERS_19.TABLE_NAME);
  11851.                     PUT_LINE ("COLUMN_NAME : " &
  11852.                           IN_PARAMETERS_19.COLUMN_NAME);
  11853.                     PUT ("ITEM");
  11854.                     PUT (5, IN_PARAMETERS_19.ITEM);
  11855.                     when GET => 
  11856.                     SCREEN_POS (13, 3);
  11857.                     GET (IN_PARAMETERS_19.TABLE_NAME);
  11858.                     SCREEN_POS (14, 4);
  11859.                     GET (IN_PARAMETERS_19.COLUMN_NAME);
  11860.                     GET (11, 5, IN_PARAMETERS_19.ITEM);
  11861.                     when others => 
  11862.                     RDWR_IN_PARAMETERS_19
  11863.                        (LOST_SWITCH, IN_PARAMETERS_19);
  11864.                 end case;
  11865.  
  11866.                 when others => 
  11867.                 case RPGW_SWITCH is
  11868.                     when PUT => 
  11869.                     PUT_LINE ("TABLE_NAME : " &
  11870.                           IN_PARAMETERS_17.TABLE_NAME);
  11871.                     PUT_LINE ("COLUMN_NAME : " &
  11872.                           IN_PARAMETERS_17.COLUMN_NAME);
  11873.                     when GET => 
  11874.                     SCREEN_POS (13, 3);
  11875.                     GET (IN_PARAMETERS_17.TABLE_NAME);
  11876.                     SCREEN_POS (14, 4);
  11877.                     GET (IN_PARAMETERS_17.COLUMN_NAME);
  11878.                     when others => 
  11879.                     RDWR_IN_PARAMETERS_17
  11880.                        (LOST_SWITCH, IN_PARAMETERS_17);
  11881.                 end case;
  11882.             end case;
  11883.             when others => 
  11884.             case RPGW_SWITCH is
  11885.                 when PUT => 
  11886.                 PUT_LINE ("TABLE_NAME : " &
  11887.                       IN_PARAMETERS_06.TABLE_NAME);
  11888.                 when GET => 
  11889.                 SCREEN_POS (13, 3);
  11890.                 GET (IN_PARAMETERS_06.TABLE_NAME);
  11891.                 when others => 
  11892.                 RDWR_IN_PARAMETERS_06
  11893.                    (LOST_SWITCH, IN_PARAMETERS_06);
  11894.             end case;
  11895.         end case;
  11896.     end case;
  11897.     PARAMETER := IN_PARAMETERS;
  11898.  
  11899.     end IN_PARAMETERS;
  11900.     procedure OUT_PARAMETERS (RPGW_SWITCH : RPGW_SWITCH_TYPE) is
  11901.  
  11902. --************************************************************************
  11903. --**                                                                    **
  11904. --**   UNIT NAME :               OUT_PARAMETERS                         **
  11905. --**   ~~~~~~~~~~~                                                      **
  11906. --************************************************************************
  11907.  
  11908.     procedure RDWR_OUT_PARAMETERS_00 is new RDWR_OUT_PARAMETERS
  11909.            (OUT_PARAMETER_00);
  11910.     procedure RDWR_OUT_PARAMETERS_04 is new RDWR_OUT_PARAMETERS
  11911.            (OUT_PARAMETER_04);
  11912.     procedure RDWR_OUT_PARAMETERS_05 is new RDWR_OUT_PARAMETERS
  11913.            (OUT_PARAMETER_05);
  11914.     procedure RDWR_OUT_PARAMETERS_06 is new RDWR_OUT_PARAMETERS
  11915.            (OUT_PARAMETER_06);
  11916.     procedure RDWR_OUT_PARAMETERS_08 is new RDWR_OUT_PARAMETERS
  11917.            (OUT_PARAMETER_08);
  11918.     procedure RDWR_OUT_PARAMETERS_14 is new RDWR_OUT_PARAMETERS
  11919.            (OUT_PARAMETER_14);
  11920.     procedure RDWR_OUT_PARAMETERS_15 is new RDWR_OUT_PARAMETERS
  11921.            (OUT_PARAMETER_15);
  11922.  
  11923.     LOST_SWITCH : LOST_SWITCH_TYPE;
  11924.  
  11925.     begin
  11926.     PARAMETER := OUT_PARAMETERS;
  11927.  
  11928.     case RPGW_SWITCH is
  11929.         when READ => 
  11930.         NEW_PAGE;
  11931.         LOST_SWITCH := LOAD;
  11932.         when WRITE => 
  11933.         NEW_PAGE;
  11934.         LOST_SWITCH := STORE;
  11935.         when PUT => 
  11936.         NEWPAGE;
  11937.         SCREEN_POS (0, 3);
  11938.         when GET =>  null;
  11939.     end case;
  11940.     case ACCESS_NB is
  11941.         when 0 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 17 | 18 | 20 |
  11942.          21 | 22 | 23 | 25 | 26 | 28 | 30 => 
  11943.         case ACCESS_NB is
  11944.             when 4 | 6 | 7 | 11 | 16 | 17 | 25 => 
  11945.             case ACCESS_NB is
  11946.                 when 4 => 
  11947.                 case RPGW_SWITCH is
  11948.                     when PUT => 
  11949.                     PUT_LINE ("RTN    := " &
  11950.                           INTEGER'IMAGE
  11951.                             (OUT_PARAMETERS_04.A));
  11952.                     PUT ("TIDD   := ");
  11953.                     for Y in 1 .. 3 loop
  11954.                         PUT (INTEGER'IMAGE
  11955.                            (OUT_PARAMETERS_04.B (Y)) &
  11956.                          "         ");
  11957.                     end loop;
  11958.                     NEW_LINE;
  11959.                     PUT ("KYIDX  := ");
  11960.                     for Y in 1 .. 5 loop
  11961.                         PUT (INTEGER'IMAGE
  11962.                            (OUT_PARAMETERS_04.C (Y)) &
  11963.                          "         ");
  11964.                     end loop;
  11965.                     NEW_LINE;
  11966.                     PUT ("ATIDX  := ");
  11967.                     for Y in 1 .. 5 loop
  11968.                         PUT (INTEGER'IMAGE
  11969.                            (OUT_PARAMETERS_04.D (Y)) &
  11970.                          "         ");
  11971.                     end loop;
  11972.                     NEW_LINE;
  11973.                     when GET => 
  11974.                     SCREEN_POS (11, 3);
  11975.                     I_GET (OUT_PARAMETERS_04.A);
  11976.                     for Y in 1 .. 3 loop
  11977.                         SCREEN_POS (11 * (Y - 1) + 11, 04);
  11978.                         I_GET (OUT_PARAMETERS_04.B (Y));
  11979.                     end loop;
  11980.                     for Y in 1 .. 5 loop
  11981.                         SCREEN_POS (11 * (Y - 1) + 11, 05);
  11982.                         I_GET (OUT_PARAMETERS_04.C (Y));
  11983.                     end loop;
  11984.                     for Y in 1 .. 5 loop
  11985.                         SCREEN_POS (11 * (Y - 1) + 11, 06);
  11986.                         I_GET (OUT_PARAMETERS_04.D (Y));
  11987.                     end loop;
  11988.                     when others => 
  11989.                     RDWR_OUT_PARAMETERS_04
  11990.                        (LOST_SWITCH, OUT_PARAMETERS_04);
  11991.                 end case;
  11992.  
  11993.                 when others => 
  11994.                 case RPGW_SWITCH is
  11995.                     when PUT => 
  11996.                     PUT_LINE ("RTN    := " &
  11997.                           INTEGER'IMAGE
  11998.                             (OUT_PARAMETERS_06.A));
  11999.                     PUT ("TIDD   := ");
  12000.                     for Y in 1 .. 3 loop
  12001.                         PUT (INTEGER'IMAGE
  12002.                            (OUT_PARAMETERS_06.B (Y)) &
  12003.                          "         ");
  12004.                     end loop;
  12005.                     NEW_LINE;
  12006.                     when GET => 
  12007.                     SCREEN_POS (11, 3);
  12008.                     I_GET (OUT_PARAMETERS_06.A);
  12009.                     for Y in 1 .. 3 loop
  12010.                         SCREEN_POS (11 * (Y - 1) + 11, 04);
  12011.                         I_GET (OUT_PARAMETERS_06.B (Y));
  12012.                     end loop;
  12013.                     when others => 
  12014.                     RDWR_OUT_PARAMETERS_06
  12015.                        (LOST_SWITCH, OUT_PARAMETERS_06);
  12016.                 end case;
  12017.             end case;
  12018.             when 5 | 8 | 15 | 21 => 
  12019.             case ACCESS_NB is
  12020.                 when 8 | 15 => 
  12021.                 case ACCESS_NB is
  12022.                     when 8 => 
  12023.                     case RPGW_SWITCH is
  12024.                         when PUT => 
  12025.                         PUT_LINE ("RTN    := " &
  12026.                               INTEGER'IMAGE
  12027.                                 (OUT_PARAMETERS_08
  12028.                                   .A));
  12029.                         PUT ("ATNAM  := " &
  12030.                              OUT_PARAMETERS_08.G);
  12031.                         NEW_LINE;
  12032.                         PUT_LINE ("ATTL   := " &
  12033.                               INTEGER'IMAGE
  12034.                                 (OUT_PARAMETERS_08
  12035.                                   .E));
  12036.                         PUT ("ATIDX  := ");
  12037.                         for Y in 1 .. 5 loop
  12038.                             PUT (INTEGER'IMAGE
  12039.                                (OUT_PARAMETERS_08
  12040.                                  .F (Y)) &
  12041.                              "         ");
  12042.                         end loop;
  12043.                         NEW_LINE;
  12044.                         PUT ("ATLEN  := ");
  12045.                         for Y in 1 .. 5 loop
  12046.                             PUT (INTEGER'IMAGE
  12047.                                (OUT_PARAMETERS_08
  12048.                                  .H (Y)) &
  12049.                              "         ");
  12050.                         end loop;
  12051.                         NEW_LINE;
  12052.                         PUT ("ATTYP  := ");
  12053.                         for Y in 1 .. 5 loop
  12054.                             PUT (INTEGER'IMAGE
  12055.                                (OUT_PARAMETERS_08
  12056.                                  .I (Y)) &
  12057.                              "         ");
  12058.                         end loop;
  12059.                         NEW_LINE;
  12060.                         when GET => 
  12061.                         SCREEN_POS (11, 3);
  12062.                         I_GET (OUT_PARAMETERS_08.A);
  12063.                         SCREEN_POS (10, 04);
  12064.                         GET (OUT_PARAMETERS_08.G);
  12065.                         SCREEN_POS (11, 14);
  12066.                         I_GET (OUT_PARAMETERS_08.E);
  12067.                         for Y in 1 .. 5 loop
  12068.                             SCREEN_POS
  12069.                                (11 * (Y - 1) + 11, 15);
  12070.                             I_GET (OUT_PARAMETERS_08.F
  12071.                                   (Y));
  12072.                         end loop;
  12073.                         for Y in 1 .. 5 loop
  12074.                             SCREEN_POS
  12075.                                (11 * (Y - 1) + 11, 16);
  12076.                             I_GET (OUT_PARAMETERS_08.H
  12077.                                   (Y));
  12078.                         end loop;
  12079.                         for Y in 1 .. 5 loop
  12080.                             SCREEN_POS
  12081.                                (11 * (Y - 1) + 11, 17);
  12082.                             I_GET (OUT_PARAMETERS_08.I
  12083.                                   (Y));
  12084.                         end loop;
  12085.                         when others => 
  12086.                         RDWR_OUT_PARAMETERS_08
  12087.                            (LOST_SWITCH,
  12088.                             OUT_PARAMETERS_08);
  12089.                     end case;
  12090.                     when others => 
  12091.                     case RPGW_SWITCH is
  12092.                         when PUT => 
  12093.                         PUT_LINE ("RTN    := " &
  12094.                               INTEGER'IMAGE
  12095.                                 (OUT_PARAMETERS_15
  12096.                                   .A));
  12097.                         PUT ("VALUE  := ");
  12098.                         for Y in 1 .. 5 loop
  12099.                             PUT (INTEGER'IMAGE
  12100.                                (OUT_PARAMETERS_15
  12101.                                  .F (Y)) &
  12102.                              "         ");
  12103.                         end loop;
  12104.                         NEW_LINE;
  12105.                         PUT_LINE ("LENR   := " &
  12106.                               INTEGER'IMAGE
  12107.                                 (OUT_PARAMETERS_15
  12108.                                   .E));
  12109.                         PUT_LINE ("FTYP   := " &
  12110.                               INTEGER'IMAGE
  12111.                                 (OUT_PARAMETERS_15
  12112.                                   .J));
  12113.                         when GET => 
  12114.                         SCREEN_POS (11, 3);
  12115.                         I_GET (OUT_PARAMETERS_15.A);
  12116.                         for Y in 1 .. 5 loop
  12117.                             SCREEN_POS
  12118.                                (11 * (Y - 1) + 11, 04);
  12119.                             I_GET (OUT_PARAMETERS_15.F
  12120.                                   (Y));
  12121.                         end loop;
  12122.                         SCREEN_POS (11, 05);
  12123.                         I_GET (OUT_PARAMETERS_15.E);
  12124.                         SCREEN_POS (11, 06);
  12125.                         I_GET (OUT_PARAMETERS_15.J);
  12126.                         when others => 
  12127.                         RDWR_OUT_PARAMETERS_15
  12128.                            (LOST_SWITCH,
  12129.                             OUT_PARAMETERS_15);
  12130.                     end case;
  12131.                 end case;
  12132.                 when others => 
  12133.                 case RPGW_SWITCH is
  12134.                     when PUT => 
  12135.                     PUT_LINE ("RTN    := " &
  12136.                           INTEGER'IMAGE
  12137.                             (OUT_PARAMETERS_05.A));
  12138.                     if ACCESS_NB = 5 then
  12139.                         PUT ("INPLEN := ");
  12140.                     else
  12141.                         PUT ("DESCR  := ");
  12142.                     end if;
  12143.                     PUT (INTEGER'IMAGE
  12144.                            (OUT_PARAMETERS_05.E));
  12145.                     when GET => 
  12146.                     SCREEN_POS (11, 3);
  12147.                     I_GET (OUT_PARAMETERS_05.A);
  12148.                     SCREEN_POS (11, 4);
  12149.                     I_GET (OUT_PARAMETERS_05.E);
  12150.                     when others => 
  12151.                     RDWR_OUT_PARAMETERS_05
  12152.                        (LOST_SWITCH, OUT_PARAMETERS_05);
  12153.                 end case;
  12154.             end case;
  12155.             when others => 
  12156.             case RPGW_SWITCH is
  12157.                 when PUT => 
  12158.                 case ACCESS_NB is
  12159.                     when 18 => 
  12160.                     PUT ("RCKEY  := ");
  12161.                     when 20 => 
  12162.                     PUT ("RETURN := ");
  12163.                     when 28 => 
  12164.                     PUT ("ATIDX  := ");
  12165.                     when others => 
  12166.                     PUT ("RTN    := ");
  12167.                 end case;
  12168.                 PUT (INTEGER'IMAGE (OUT_PARAMETERS_00.A));
  12169.                 when GET => 
  12170.                 SCREEN_POS (11, 3);
  12171.                 I_GET (OUT_PARAMETERS_00.A);
  12172.                 when others => 
  12173.                 RDWR_OUT_PARAMETERS_00
  12174.                    (LOST_SWITCH, OUT_PARAMETERS_00);
  12175.             end case;
  12176.         end case;
  12177.         when 14 => 
  12178.         case RPGW_SWITCH is
  12179.             when PUT => 
  12180.             PUT ("ACSIFO := ");
  12181.             for Y in 1 .. 5 loop
  12182.                 PUT (INTEGER'IMAGE (OUT_PARAMETERS_14.K (Y)) &
  12183.                  "         ");
  12184.             end loop;
  12185.             when GET => 
  12186.             for Y in 1 .. 5 loop
  12187.                 SCREEN_POS (11 * (Y - 1) + 11, 03);
  12188.                 I_GET (OUT_PARAMETERS_14.K (Y));
  12189.             end loop;
  12190.             when others => 
  12191.             RDWR_OUT_PARAMETERS_14 (LOST_SWITCH, OUT_PARAMETERS_14);
  12192.         end case;
  12193.         when 1 | 2 | 3 | 12 | 13 | 19 | 24 | 27 | 29 | 31 => 
  12194.         null;
  12195.     end case;
  12196.     PARAMETER := IN_PARAMETERS;
  12197.  
  12198.     end OUT_PARAMETERS;
  12199.  
  12200. end TOOLS;
  12201.  
  12202.  
  12203.  
  12204.  
  12205. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  12206. --warespec.txt
  12207. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  12208. package WAREHOUSE is
  12209.  
  12210.  
  12211.     procedure INITIALIZE;
  12212.  
  12213. --************************************************************************
  12214. --**                                    **
  12215. --**      UNIT NAME :                INITIALIZE                **
  12216. --**      ~~~~~~~~~~~                            **
  12217. --**                                    **
  12218. --** DESCRIPTION ------------------------------------------------------ **
  12219. --**                                    **
  12220. --**  This procedure initialize all the pointer tables.            **
  12221. --**                                                                **
  12222. --**  There is one pointer table for each interface procedure.        **
  12223. --**                                                                **
  12224. --**  The pointer table content is :                                       **
  12225. --**      - parameters addresses.                                       **
  12226. --**      - test case names.                                            **
  12227. --**                                                                **
  12228. --**  This procedure also initialize :                    **
  12229. --**       - the in_parameters file                                 **
  12230. --**       - the table descriptors file                             **
  12231. --**       - the out_parameters file                                **
  12232. --**                                                                **
  12233. --**                                    **
  12234. --************************************************************************
  12235.  
  12236.     procedure INFORM_ABOUT_RESULT;
  12237.  
  12238. --************************************************************************
  12239. --**                                    **
  12240. --**      UNIT NAME :                INFORM_ABOUT_RESULT        **
  12241. --**      ~~~~~~~~~~~                            **
  12242. --**                                    **
  12243. --** DESCRIPTION ------------------------------------------------------ **
  12244. --**                                    **
  12245. --**  This procedure display the log file.                      **
  12246. --**                                      **
  12247. --**  The log file content is :                        **
  12248. --**      - the date of the execution                    **
  12249. --**      - the interface procedure name                **
  12250. --**      - the test case name                        **
  12251. --**      - the interface procedure in_parameters            **
  12252. --**      - the table_descriptors                       **
  12253. --**      - for each access procedure :                    **
  12254. --**            - the name                                    **
  12255. --**            - the in_parameters                         **
  12256. --**            - the out_parameters                        **
  12257. --**      - the interface procedure out_parameters or the raised    **
  12258. --**        exceptions                                                 **
  12259. --**                                      **
  12260. --************************************************************************
  12261.  
  12262.     procedure EXECUTE_AUTOMATIC_VERSION;
  12263.  
  12264. --************************************************************************
  12265. --**                                    **
  12266. --**      UNIT NAME :                EXECUTE_AUTOMATIC_VERSION        **
  12267. --**      ~~~~~~~~~~~                            **
  12268. --**                                    **
  12269. --** DESCRIPTION ------------------------------------------------------ **
  12270. --**                                    **
  12271. --**  This procedure will automatically    test all the ADA/DAMES            **
  12272. --**  interface procedures with the previous recorded test cases.    **          
  12273. --**                                    **        
  12274. --**                                    **      
  12275. --**                                    **
  12276. --************************************************************************
  12277.  
  12278.  
  12279.  
  12280.     procedure CREATE_TEST_CASE;
  12281.  
  12282. --************************************************************************
  12283. --**                                    **
  12284. --**      UNIT NAME :                CREATE_TEST_CASE            **
  12285. --**      ~~~~~~~~~~~                            **
  12286. --**                                    **
  12287. --** DESCRIPTION ------------------------------------------------------ **
  12288. --**                                    **
  12289. --**  This procedure create one test_case.                **
  12290. --**                                    **
  12291. --**  A test_case is a set of three kinds of parameter :        **
  12292. --**     - the ADA/DAMES interface procedure in_parameters        **
  12293. --**     - the table_descriptors                    **
  12294. --**     - the access procedure out_parameters.                **
  12295. --**                                    **
  12296. --**  Each test_case is designed to check one property of the         **
  12297. --**  interface procedure.                        **
  12298. --**                                    **
  12299. --**                                    **
  12300. --************************************************************************
  12301.  
  12302.     procedure EXECUTE_TEST_CASE;
  12303.  
  12304. --************************************************************************
  12305. --**                                    **
  12306. --**      UNIT NAME :                EXECUTE_TEST_CASE            **
  12307. --**      ~~~~~~~~~~~                            **
  12308. --**                                    **
  12309. --** DESCRIPTION ------------------------------------------------------ **
  12310. --**                                    **
  12311. --**  This procedure will execute one or more previous recorded         **     
  12312. --**  test cases of the chosen interface procedure.             **
  12313. --**                                    **
  12314. --**                                    **
  12315. --************************************************************************
  12316.  
  12317.  
  12318.  
  12319.     procedure MODIFY_TEST_CASE;
  12320.  
  12321. --************************************************************************
  12322. --**                                    **
  12323. --**      UNIT NAME :                MODIFY_TEST_CASE            **
  12324. --**      ~~~~~~~~~~~                            **
  12325. --**                                    **
  12326. --** DESCRIPTION ------------------------------------------------------ **
  12327. --**                                    **
  12328. --**  This procedure will modify :                                        **
  12329. --**       or the interface procedure in_parameters               **
  12330. --**       or the table_descriptors                       **
  12331. --**       or the access procedure out_parameters.            **
  12332. --**                                    **
  12333. --**                                    **
  12334. --************************************************************************
  12335.     procedure DELETE_TEST_CASE;
  12336.  
  12337. --************************************************************************
  12338. --**                                    **
  12339. --**      UNIT NAME :                DELETE_TEST_CASE            **
  12340. --**      ~~~~~~~~~~~                            **
  12341. --**                                    **
  12342. --** DESCRIPTION ------------------------------------------------------ **
  12343. --**                                    **
  12344. --**  This procedure will delete one or more previous recorded          **     
  12345. --**  test cases of the chosen interface procedure.                **
  12346. --**                                                                    **
  12347. --**                                                                    **
  12348. --************************************************************************
  12349.  
  12350.  
  12351. end WAREHOUSE;
  12352. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  12353. --warehouse.txt
  12354. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  12355. with TEXT_IO;
  12356. use TEXT_IO;
  12357. with DIRECT_IO;
  12358. with BOTH_VARIABLES;
  12359. use BOTH_VARIABLES;
  12360. with TOOLS;
  12361. use TOOLS;
  12362. with DISPLAY;
  12363. use DISPLAY;
  12364. with INSTANTIATED;
  12365. use INSTANTIATED;
  12366.  
  12367. package body WAREHOUSE is
  12368.  
  12369.  
  12370. --***************************************************************************--
  12371. --                             internal variables                            --
  12372. --***************************************************************************--
  12373.  
  12374.     LAST_TABLE_DESCRIPTORS : BOOLEAN;
  12375.     GOT                    : STRING (1 .. 20) := (others => ' ');
  12376. --***************************************************************************--
  12377. --                             internal procedure                           --
  12378. --***************************************************************************--
  12379.  
  12380. -------------------------------------------------------------------------------
  12381. --                      CHOOSE_TEST_CASE_NAME                                --
  12382. -------------------------------------------------------------------------------
  12383.     procedure CHOOSE_TEST_CASE_NAME (LAST_TABLE_DESCRIPTORS : out BOOLEAN) is
  12384.  
  12385.     TEST_CASE_NAME : STRING (1 .. 5) := (others => ' ');
  12386.  
  12387.     begin
  12388.     NEW_PAGE;
  12389.     PUT (TEST_BED_FUNCTION'IMAGE (T_B_FUNCTION) &
  12390.          " interface procedure " &
  12391.          INTERFACE_PROCEDURE_NAME'IMAGE (INTERFACE_PR_NAME) & " ");
  12392.  
  12393.     case T_B_FUNCTION is
  12394.         when CREATE => 
  12395.         case PARAMETER is
  12396.             when IN_PARAMETERS => 
  12397.             PUT (PARAMETER_TYPE'IMAGE (PARAMETER));
  12398.             when TABLE_DESCRIPTORS => 
  12399.             PUT (PARAMETER_TYPE'IMAGE (PARAMETER));
  12400.             DISPL (0, 6, "last_table_descriptors");
  12401.             when OUT_PARAMETERS => 
  12402.             NEW_LINE;
  12403.             PUT ("access procedure " &
  12404.                  PARAMETER_TYPE'IMAGE (PARAMETER));
  12405.         end case;
  12406.         when others =>  null;
  12407.     end case;
  12408.  
  12409.     SCREEN_POS (0, 7);
  12410.  
  12411.     for I in PT_TABLE.TEST_CASE'RANGE loop
  12412.         if PT_TABLE.TEST_CASE (I).IS_OPEN then
  12413.         PUT (PT_TABLE.TEST_CASE (I).NAME);
  12414.         PUT ("     ");
  12415.         end if;
  12416.     end loop;
  12417.  
  12418.     case T_B_FUNCTION is
  12419.         when CREATE => 
  12420.         DISPL (0, 21,
  12421.                "choose the test case name which you want to look like.");
  12422.         when DELETE => 
  12423.         DISPL (0, 21,
  12424.                "choose the test case name which you want to delete.");
  12425.         when EXECUTE => 
  12426.         DISPL (0, 21,
  12427.                "choose the test case name which you want to execute.");
  12428.         when MODIFY => 
  12429.         DISPL (0, 21,
  12430.                "choose the test case name which you want to modify.");
  12431.     end case;
  12432.     DISPL (0, 22, " test case name : ");
  12433.     TEST_CASE_NAME_QUEST:
  12434.     loop
  12435.         loop
  12436.         SCREEN_POS (18, 22);
  12437.         GET_LINE (GOT, LAST);
  12438.         exit when LAST in 1 .. 5;
  12439.         end loop;
  12440.  
  12441.         TEST_CASE_NAME := GOT (1 .. LAST) &
  12442.                   (LAST + 1 .. TEST_CASE_NAME'LENGTH => ' ');
  12443.         if TEST_CASE_NAME = "last_" then
  12444.         LAST_TABLE_DESCRIPTORS := TRUE;
  12445.         exit;
  12446.         else
  12447.         LAST_TABLE_DESCRIPTORS := FALSE;
  12448.         for I in PT_TABLE.TEST_CASE'RANGE loop
  12449.             if PT_TABLE.TEST_CASE (I).IS_OPEN and then
  12450.                PT_TABLE.TEST_CASE (I).NAME = TEST_CASE_NAME then
  12451.             TEST_CASE_NB := I;
  12452.             exit TEST_CASE_NAME_QUEST;
  12453.             end if;
  12454.         end loop;
  12455.         end if;
  12456.     end loop TEST_CASE_NAME_QUEST;
  12457.     NEW_PAGE;
  12458.     end CHOOSE_TEST_CASE_NAME;
  12459.  
  12460.  
  12461.     procedure INITIALIZE is
  12462.  
  12463. --************************************************************************
  12464. --**                                                                    **
  12465. --**      UNIT NAME :                INITIALIZE                         **
  12466. --**      ~~~~~~~~~~~                                                   **
  12467. --************************************************************************
  12468.  
  12469.     package D_IO_1 is new DIRECT_IO (POINTER_TABLE);
  12470.     package D_IO_2 is new DIRECT_IO (IN_PARAMETER_00);
  12471.     package D_IO_3 is new DIRECT_IO (TABLE_DESCRIPTORX);
  12472.     package D_IO_4 is new DIRECT_IO (OUT_PARAMETER_00);
  12473.  
  12474.     FILE_1   : D_IO_1.FILE_TYPE;
  12475.     FILE_2   : D_IO_2.FILE_TYPE;
  12476.     FILE_3   : D_IO_3.FILE_TYPE;
  12477.     FILE_4   : D_IO_4.FILE_TYPE;
  12478.     PT_TABLE : POINTER_TABLE;
  12479.  
  12480.     begin
  12481.  
  12482.     PT_TABLE.IS_EMPTY := TRUE;
  12483.     PT_TABLE.IS_FULL := FALSE;
  12484.  
  12485.     for I in PT_TABLE.TEST_CASE'RANGE loop
  12486.         PT_TABLE.TEST_CASE (I).IS_OPEN := FALSE;
  12487.     end loop;
  12488.  
  12489.     D_IO_1.CREATE (FILE => FILE_1, NAME => "t_bed_pointer_table");
  12490.  
  12491.     for I in INTERFACE_NUMBER loop
  12492.         D_IO_1.WRITE (FILE_1, PT_TABLE, D_IO_1.POSITIVE_COUNT (I + 1));
  12493.     end loop;
  12494.  
  12495.     D_IO_1.CLOSE (FILE_1);
  12496.  
  12497.     for I in INTERFACE_NUMBER loop
  12498.         D_IO_2.CREATE (FILE => FILE_2,
  12499.                NAME => "t_bed_in_p_" &
  12500.                    INTERFACE_PROCEDURE_NAME'IMAGE
  12501.                      (INTERFACE_PROCEDURE_NAME'VAL (I)));
  12502.         D_IO_2.CLOSE (FILE_2);
  12503.     end loop;
  12504.  
  12505.     D_IO_3.CREATE (FILE => FILE_3, NAME => "t_bed_table_descriptors");
  12506.     D_IO_3.CLOSE (FILE_3);
  12507.  
  12508.     for I in ACCESS_NUMBER loop
  12509.         D_IO_4.CREATE (FILE => FILE_4,
  12510.                NAME => "t_bed_out_p_" &
  12511.                    ACCESS_PROCEDURE_NAME'IMAGE
  12512.                      (ACCESS_PROCEDURE_NAME'VAL (I)));
  12513.         D_IO_4.CLOSE (FILE_4);
  12514.     end loop;
  12515.  
  12516.     end INITIALIZE;
  12517.  
  12518.     procedure INFORM_ABOUT_RESULT is
  12519.  
  12520. --************************************************************************
  12521. --**                                                                    **
  12522. --**      UNIT NAME :                INFORM_ABOUT_RESULT                **
  12523. --**      ~~~~~~~~~~~                                                   **
  12524. --************************************************************************
  12525.  
  12526.     LINE               : STRING (1 .. 200);
  12527.     LINE_RANGE         : NATURAL := 0;
  12528.     LINE_POSITION      : NATURAL := 0;
  12529.     LAST_LINE_POSITION : NATURAL := 0;
  12530.     begin
  12531.     CLOSE (LOG_FILE);
  12532.     OPEN (LOG_FILE, IN_FILE, "log_file");
  12533.     loop
  12534.         loop
  12535.         begin
  12536.             PUT ("line position :" & NATURAL'IMAGE (LINE_POSITION));
  12537.             PUT ("   next line position ? ");
  12538.             GET_LINE (LINE, LAST);
  12539.             LINE_POSITION := NATURAL'VALUE (LINE (1 .. LAST));
  12540.             exit;
  12541.         exception
  12542.             when CONSTRAINT_ERROR =>  null;
  12543.             when others =>  null;
  12544.         end;
  12545.         end loop;
  12546.         if LINE_POSITION < LAST_LINE_POSITION the|
  12547.         CLOSE (LOG_FILE);
  12548.         OPEN (LOG_FILE, IN_FILE, "log_file");
  12549.         LAST_LINE_POSITION := 0;
  12550.         end if;
  12551.         LINE_RANGE := LINE_POSITION - LAST_LINE_POSITION;
  12552.         LAST_LINE_POSITION := LINE_POSITION;
  12553.         for I in 0 .. LINE_RANGE loop
  12554.         GET_LINE (LOG_FILE, LINE, LAST);
  12555.         PUT_LINE (LINE (1 .. LAST));
  12556.         end loop;
  12557.     end loop;
  12558.     exception
  12559.     when END_ERROR => 
  12560.         CLOSE (LOG_FILE);
  12561.         CREATE (LOG_FILE, OUT_FILE, "log_file");
  12562.     end INFORM_ABOUT_RESULT;
  12563.  
  12564.     procedure EXECUTE_AUTOMATIC_VERSION is
  12565.  
  12566. --************************************************************************
  12567. --**                                                                    **
  12568. --**      UNIT NAME :                EXECUTE_AUTOMATIC_VERSION          **
  12569. --**      ~~~~~~~~~~~                                                   **
  12570. --**                                                                    **
  12571. --************************************************************************
  12572.  
  12573.     begin
  12574.     for U in INTERFACE_NUMBER loop
  12575.         INTERFACE_NB := U;
  12576.         RDWR_POINTER_TABLE (LOAD);
  12577.         INTERFACE_PR_NAME := INTERFACE_PROCEDURE_NAME'VAL (INTERFACE_NB);
  12578.  
  12579.         if not PT_TABLE.IS_EMPTY then
  12580.         for I in PT_TABLE.TEST_CASE'RANGE loop
  12581.             if PT_TABLE.TEST_CASE (I).IS_OPEN then
  12582.             TEST_CASE_NB := I;
  12583.             AUTOMATIC_VERSION := TRUE;
  12584.             EXECUTE_ONE_TEST_CASE;
  12585.             AUTOMATIC_VERSION := FALSE;
  12586.             end if;
  12587.         end loop;
  12588.         end if;
  12589.     end loop;
  12590.     end EXECUTE_AUTOMATIC_VERSION;
  12591.  
  12592.  
  12593.     procedure CREATE_TEST_CASE is
  12594.  
  12595. --************************************************************************
  12596. --**                                                                    **
  12597. --**      UNIT NAME :                CREATE_TEST_CASE                   **
  12598. --**      ~~~~~~~~~~~                                                   **
  12599. --**                                                                    **
  12600. --************************************************************************
  12601.  
  12602.     U   : INTEGER := 1;
  12603.     TCN : INTEGER := 1;
  12604.  
  12605.     begin
  12606.     T_B_FUNCTION := CREATE;
  12607.  
  12608.     if PT_TABLE.IS_FULL then
  12609.         NEW_PAGE;
  12610.         DISPL (20, 04, "you could only create 80 test cases !");
  12611.         DISPL (20, 05, "you would like 81 test cases !");
  12612.         DISPL (20, 06, "you are very hungry !");
  12613.         DISPL (20, 07, "delete a test case or be hungry !");
  12614.         STOP;
  12615.     else
  12616.         if PT_TABLE.IS_EMPTY then
  12617.  
  12618.         PT_TABLE.IS_EMPTY := FALSE;
  12619.         PT_TABLE.TEST_CASE (1).IS_OPEN := TRUE;
  12620.         TEST_CASE_NB := 1;
  12621.  
  12622.         if IN_PARAMETER_IS_OPEN (INTERFACE_NB) then
  12623.             IN_PARAMETERS (PUT);
  12624.             IN_PARAMETERS (GET);
  12625.         end if;
  12626.  
  12627.         INITIALIZE_STATUS;
  12628.         UPDATE_STATUS;
  12629.  
  12630.         for I in ACC_LIST_NUMBER loop
  12631.             if ACC_LIST (INTERFACE_NB, I) /= 99 then
  12632.             ACCESS_NB := ACC_LIST (INTERFACE_NB, I);
  12633.             ACCESS_PR_NAME := ACCESS_PROCEDURE_NAME'VAL (ACCESS_NB);
  12634.             OUT_PARAMETERS (PUT);
  12635.             OUT_PARAMETERS (GET);
  12636.             ACC_LI_NB := I;
  12637.             OUT_PARAMETERS (WRITE);
  12638.             else
  12639.             exit;
  12640.             end if;
  12641.         end loop;
  12642.         else
  12643. -- looking for a test case number       
  12644.         while U in PT_TABLE.TEST_CASE'RANGE and then
  12645.               PT_TABLE.TEST_CASE (U).IS_OPEN loop
  12646.             U := U + 1;
  12647.         end loop;
  12648.         if IN_PARAMETER_IS_OPEN (INTERFACE_NB) then
  12649.             PARAMETER := IN_PARAMETERS;
  12650.             CHOOSE_TEST_CASE_NAME (LAST_TABLE_DESCRIPTORS);
  12651.             IN_PARAMETERS (READ);
  12652.             IN_PARAMETERS (PUT);
  12653.  
  12654.             if MODIFY then
  12655.             IN_PARAMETERS (GET);
  12656.             end if;
  12657.         end if;
  12658.  
  12659.         PARAMETER := TABLE_DESCRIPTORS;
  12660.         CHOOSE_TEST_CASE_NAME (LAST_TABLE_DESCRIPTORS);
  12661.  
  12662.         if not LAST_TABLE_DESCRIPTORS then
  12663.             RDWR_TABLE_DESCRIPTORS (LOAD);
  12664.         end if;
  12665.  
  12666.         UPDATE_STATUS;
  12667.  
  12668.         if ACC_LIST (INTERFACE_NB, ACC_LIST_NUMBER'FIRST) /= 99 then
  12669.             PARAMETER := OUT_PARAMETERS;
  12670.             CHOOSE_TEST_CASE_NAME (LAST_TABLE_DESCRIPTORS);
  12671.             TCN := TEST_CASE_NB;
  12672.  
  12673.             for I in ACC_LIST_NUMBER loop
  12674.             if ACC_LIST (INTERFACE_NB, I) /= 99 then
  12675.                 ACCESS_NB := ACC_LIST (INTERFACE_NB, I);
  12676.                 ACCESS_PR_NAME :=
  12677.                   ACCESS_PROCEDURE_NAME'VAL (ACCESS_NB);
  12678.                 ACC_LI_NB := I;
  12679.                 TEST_CASE_NB := TCN;
  12680.                 OUT_PARAMETERS (READ);
  12681.                 OUT_PARAMETERS (PUT);
  12682.  
  12683.                 if MODIFY then
  12684.                 OUT_PARAMETERS (GET);
  12685.                 end if;
  12686.  
  12687.                 TEST_CASE_NB := U;
  12688.                 OUT_PARAMETERS (WRITE);
  12689.             else
  12690.                 exit;
  12691.             end if;
  12692.             end loop;
  12693.         end if;
  12694.  
  12695.         PT_TABLE.TEST_CASE (U).IS_OPEN := TRUE;
  12696.         TEST_CASE_NB := U;
  12697.  
  12698.         if U = PT_TABLE.TEST_CASE'LAST then
  12699.             PT_TABLE.IS_FULL := TRUE;
  12700.         end if;
  12701.         end if;
  12702.         SCREEN_POS (0, 22);
  12703.         PUT ("what name for the new test case ? Test case name : .....");
  12704.         NEW_LINE;
  12705.         PUT ((1 .. 79 => ' '));
  12706.  
  12707.         loop
  12708.         SCREEN_POS (51, 22);
  12709.         GET_LINE (GOT, LAST);
  12710.         exit when LAST in 1 .. 5;
  12711.         end loop;
  12712.  
  12713.         PT_TABLE.TEST_CASE (TEST_CASE_NB).NAME :=
  12714.           GOT (1 .. LAST) &
  12715.           (LAST + 1 .. PT_TABLE.TEST_CASE (TEST_CASE_NB).NAME'LENGTH =>
  12716.          ' ');
  12717.  
  12718.         IN_PARAMETERS (WRITE);
  12719.         RDWR_TABLE_DESCRIPTORS (STORE);
  12720.         RDWR_POINTER_TABLE (STORE);
  12721.     end if;
  12722.  
  12723.     end CREATE_TEST_CASE;
  12724.     procedure EXECUTE_TEST_CASE is
  12725.  
  12726. --************************************************************************
  12727. --**                                                                    **
  12728. --**      UNIT NAME :                EXECUTE_TEST_CASE                  **
  12729. --**      ~~~~~~~~~~~                                                   **
  12730. --**                                                                    **
  12731. --************************************************************************
  12732.  
  12733.     begin
  12734.     T_B_FUNCTION := EXECUTE;
  12735.     if PT_TABLE.IS_EMPTY then
  12736.         NEW_LINE (4);
  12737.         PUT ("no created test case !");
  12738.         STOP;
  12739.         NEW_PAGE;
  12740.     else
  12741.         MENU_1_LOOP:
  12742.         loop
  12743.         NEW_PAGE;
  12744.         PUT (TEST_BED_FUNCTION'IMAGE (T_B_FUNCTION) &
  12745.              " interface procedure " &
  12746.              INTERFACE_PROCEDURE_NAME'IMAGE (INTERFACE_PR_NAME));
  12747.  
  12748.         DISPL (00, 07, "       - Menu_3                              ");
  12749.         DISPL (00, 08, "       - All the test cases will be executed ");
  12750.         DISPL (00, 09, "       - One test case will be executed      ");
  12751.         loop
  12752.             ROW := 7;
  12753.             COLUMN := 7;
  12754.             CHOICE (R_O_W, 9, ROW, COLUMN);
  12755.             if ROW <= 9 then  exit;  end if;
  12756.         end loop;
  12757.  
  12758.         NEW_PAGE;
  12759.         case ROW is
  12760.             when 7 =>  exit;
  12761.             when 8 => 
  12762.             for I in PT_TABLE.TEST_CASE'RANGE loop
  12763.                 if PT_TABLE.TEST_CASE (I).IS_OPEN then
  12764.                 TEST_CASE_NB := I;
  12765.                 AUTOMATIC_VERSION := TRUE;
  12766.                 EXECUTE_ONE_TEST_CASE;
  12767.                 AUTOMATIC_VERSION := FALSE;
  12768.                 end if;
  12769.             end loop;
  12770.             when 9 => 
  12771.             CHOOSE_TEST_CASE_NAME (LAST_TABLE_DESCRIPTORS);
  12772.             AUTOMATIC_VERSION := FALSE;
  12773.             EXECUTE_ONE_TEST_CASE;
  12774.             when others =>  null;
  12775.         end case;
  12776.         end loop MENU_1_LOOP;
  12777.     end if;
  12778.     end EXECUTE_TEST_CASE;
  12779.  
  12780.     procedure DELETE_TEST_CASE is
  12781. --************************************************************************
  12782. --**                                                                    **
  12783. --**      UNIT NAME :                DELETE_TEST_CASE                   **
  12784. --**      ~~~~~~~~~~~                                                   **
  12785. --************************************************************************
  12786.     begin
  12787.     T_B_FUNCTION := DELETE;
  12788.  
  12789.     if PT_TABLE.IS_EMPTY then
  12790.         NEW_LINE (4);
  12791.         PUT ("no created test case !");
  12792.         STOP;
  12793.         NEW_PAGE;
  12794.     else
  12795.         MENU_1_LOOP:
  12796.         loop
  12797.         NEW_PAGE;
  12798.         PUT (TEST_BED_FUNCTION'IMAGE (T_B_FUNCTION) &
  12799.              " interface procedure " &
  12800.              INTERFACE_PROCEDURE_NAME'IMAGE (INTERFACE_PR_NAME));
  12801.  
  12802.         DISPL (00, 07, "       - Menu_3                            ");
  12803.         DISPL (00, 08, "       - All the test cases will be deleted");
  12804.         DISPL (00, 09, "       - One test case will be deleted     ");
  12805.         loop
  12806.             ROW := 7;
  12807.             COLUMN := 7;
  12808.             CHOICE (R_O_W, 9, ROW, COLUMN);
  12809.             if ROW <= 9 then  exit;  end if;
  12810.         end loop;
  12811.  
  12812.         NEW_PAGE;
  12813.         case ROW is
  12814.             when 7 =>  exit;
  12815.             when 8 => 
  12816.             PT_TABLE.IS_EMPTY := TRUE;
  12817.             PT_TABLE.IS_FULL := FALSE;
  12818.  
  12819.             for I in PT_TABLE.TEST_CASE'RANGE loop
  12820.                 PT_TABLE.TEST_CASE (I).IS_OPEN := FALSE;
  12821.             end loop;
  12822.             when 9 => 
  12823.             CHOOSE_TEST_CASE_NAME (LAST_TABLE_DESCRIPTORS);
  12824.             PT_TABLE.TEST_CASE (TEST_CASE_NB).IS_OPEN := FALSE;
  12825.             if PT_TABLE.IS_FULL then
  12826.                 PT_TABLE.IS_FULL := FALSE;
  12827.             else
  12828.                 for I in PT_TABLE.TEST_CASE'RANGE loop
  12829.                 exit when PT_TABLE.TEST_CASE (I).IS_OPEN;
  12830.                 if I = PT_TABLE.TEST_CASE'LAST then
  12831.                     PT_TABLE.IS_EMPTY := TRUE;
  12832.                 end if;
  12833.                 end loop;
  12834.             end if;
  12835.             when others =>  null;
  12836.         end case;
  12837.         end loop MENU_1_LOOP;
  12838.         RDWR_POINTER_TABLE (STORE);
  12839.     end if;
  12840.     end DELETE_TEST_CASE;
  12841.  
  12842.  
  12843.     procedure MODIFY_TEST_CASE is
  12844.  
  12845. --************************************************************************
  12846. --**                                                                    **
  12847. --**      UNIT NAME :                MODIFY_TEST_CASE                   **
  12848. --**      ~~~~~~~~~~~                                                   **
  12849. --**                                                                    **
  12850. --************************************************************************
  12851.  
  12852.     begin
  12853.     T_B_FUNCTION := MODIFY;
  12854.  
  12855.     if PT_TABLE.IS_EMPTY then
  12856.         NEW_LINE (4);
  12857.         PUT ("no created test case !");
  12858.         STOP;
  12859.     else
  12860.         CHOOSE_TEST_CASE_NAME (LAST_TABLE_DESCRIPTORS);
  12861.  
  12862.         if IN_PARAMETER_IS_OPEN (INTERFACE_NB) then
  12863.         IN_PARAMETERS (READ);
  12864.         IN_PARAMETERS (PUT);
  12865.         if MODIFY then
  12866.             IN_PARAMETERS (GET);
  12867.             IN_PARAMETERS (WRITE);
  12868.         end if;
  12869.         end if;
  12870.  
  12871.         RDWR_TABLE_DESCRIPTORS (LOAD);
  12872.         UPDATE_STATUS;
  12873.         RDWR_TABLE_DESCRIPTORS (STORE);
  12874.  
  12875.         for I in ACC_LIST_NUMBER loop
  12876.         if ACC_LIST (INTERFACE_NB, I) /= 99 then
  12877.             ACCESS_NB := ACC_LIST (INTERFACE_NB, I);
  12878.             ACCESS_PR_NAME := ACCESS_PROCEDURE_NAME'VAL (ACCESS_NB);
  12879.             ACC_LI_NB := I;
  12880.             OUT_PARAMETERS (READ);
  12881.             OUT_PARAMETERS (PUT);
  12882.  
  12883.             if MODIFY then
  12884.             OUT_PARAMETERS (GET);
  12885.             OUT_PARAMETERS (WRITE);
  12886.             end if;
  12887.         else
  12888.             exit;
  12889.         end if;
  12890.         end loop;
  12891.     end if;
  12892.     NEW_PAGE;
  12893.  
  12894.     end MODIFY_TEST_CASE;
  12895.  
  12896. end WAREHOUSE;
  12897.  
  12898. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  12899. --f77call.txt
  12900. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  12901. with F77_ACCESS;
  12902. with ADA_FORTRAN;
  12903. with CONVERSION;
  12904.  
  12905. package body F77_CALLABLES is
  12906.  
  12907.     L : constant := 10;
  12908.         -- all db, table, and column names are supposed to be exactly  L
  12909.         -- characters  long,  and  some  of  them  must  be  translated
  12910.         -- into a three integers array to be send to the Fortran, while they
  12911.         -- are declared this way in the underlying subroutines.
  12912.  
  12913.     procedure ADA_ADDATR (RCKEY  : INTEGER;
  12914.                           ATNAM  : STRING;
  12915.                           ATYPE  : INTEGER;
  12916.                           ATLEN  : INTEGER;
  12917.                           DOMNAM : STRING;
  12918.                           RTN    : out INTEGER) is
  12919.         INTER1 : F77_ACCESS.INTER_TYPE (N => 3);
  12920.         INTER2 : F77_ACCESS.INTER_TYPE (N => 3);
  12921.     begin
  12922.         INTER1.INTEGER_ARRAY := CONVERSION.F77_STRING (ATNAM (1 .. 10) & "  ");
  12923.         INTER2.INTEGER_ARRAY := CONVERSION.F77_STRING (DOMNAM (1 .. 10)& "  ");
  12924.  
  12925.         F77_ACCESS.AADDATR (RCKEY, INTER1, ATYPE, ATLEN, INTER2, RTN);
  12926.     end ADA_ADDATR;
  12927.  
  12928.  
  12929.     procedure ADA_CLOSDB is
  12930.     begin
  12931.         F77_ACCESS.ACLOSDB;
  12932.     end ADA_CLOSDB;
  12933.  
  12934.  
  12935.     procedure ADA_CLOSER (DESCR : INTEGER) is
  12936.     begin
  12937.         F77_ACCESS.ACLOSER (DESCR);
  12938.     end ADA_CLOSER;
  12939.  
  12940.  
  12941.     procedure ADA_CLRELS is
  12942.     begin
  12943.         F77_ACCESS.ACLRELS;
  12944.     end ADA_CLRELS;
  12945.  
  12946.  
  12947. --  procedure ADA_CREATT (DESCR : INTEGER; RTN : out INTEGER) is
  12948. --  begin
  12949. --      F77_ACCESS.ACREATT (DESCR, RTN);
  12950. --  end ADA_CREATT;
  12951.     procedure ADA_DADD (DESCR  : INTEGER;
  12952.                         KYNAM  : STRING;
  12953.                         KYIDX  : in out INTEGER_ARRAY_TYPE;
  12954.                         KYVAL0 : STRING;
  12955.                         KYTL   : INTEGER;
  12956.                         KYTLEN : INTEGER_ARRAY_TYPE;
  12957.                         KYTYP  : INTEGER_ARRAY_TYPE;
  12958.                         ATNAM  : STRING;
  12959.                         ATIDX  : in out INTEGER_ARRAY_TYPE;
  12960.                         ATTL   : INTEGER;
  12961.                         ATLEN  : INTEGER_ARRAY_TYPE;
  12962.                         ATTYP  : INTEGER_ARRAY_TYPE;
  12963.                         TIDD   : in out TIDD_TYPE;
  12964.                         RTN    : out INTEGER) is
  12965.  
  12966.         INTER1 : F77_ACCESS.INTER_TYPE (N => KYNAM'LENGTH);
  12967.         INTER2 : F77_ACCESS.INTER_TYPE (N => KYIDX'LENGTH);
  12968.         INTER3 : F77_ACCESS.INTER_TYPE (N => KYVAL0'LENGTH);
  12969.         INTER4 : F77_ACCESS.INTER_TYPE (N => KYTLEN'LENGTH);
  12970.         INTER5 : F77_ACCESS.INTER_TYPE (N => KYTYP'LENGTH);
  12971.         INTER6 : F77_ACCESS.INTER_TYPE (N => ATNAM'LENGTH);
  12972.         INTER7 : F77_ACCESS.INTER_TYPE (N => ATIDX'LENGTH);
  12973.         INTER8 : F77_ACCESS.INTER_TYPE (N => ATLEN'LENGTH);
  12974.         INTER9 : F77_ACCESS.INTER_TYPE (N => ATTYP'LENGTH);
  12975.         INTER0 : F77_ACCESS.INTER_TYPE (N => 3);
  12976.     begin
  12977.         INTER2.INTEGER_ARRAY := KYIDX;
  12978.         INTER4.INTEGER_ARRAY := KYTLEN;
  12979.         INTER5.INTEGER_ARRAY := KYTYP;
  12980.         INTER7.INTEGER_ARRAY := ATIDX;
  12981.         INTER8.INTEGER_ARRAY := ATLEN;
  12982.         INTER9.INTEGER_ARRAY := ATTYP;
  12983.         INTER0.INTEGER_ARRAY := TIDD;
  12984.  
  12985.         for I in 1 .. INTER1.N loop
  12986.             INTER1.INTEGER_ARRAY (I) := CHARACTER'POS (KYNAM (I));
  12987.         end loop;
  12988.  
  12989.         for I in 1 .. INTER3.N loop
  12990.             INTER3.INTEGER_ARRAY (I) := CHARACTER'POS (KYVAL0 (I));
  12991.         end loop;
  12992.  
  12993.         for I in 1 .. INTER6.N loop
  12994.             INTER6.INTEGER_ARRAY (I) := CHARACTER'POS (ATNAM (I));
  12995.         end loop;
  12996.  
  12997.         F77_ACCESS.ADADD
  12998.            (DESCR, INTER1, INTER2, INTER3, KYTL, INTER4, INTER5, INTER6,
  12999.             INTER7, ATTL, INTER8, INTER9, INTER0, RTN);
  13000.         KYIDX := INTER2.INTEGER_ARRAY;
  13001.         ATIDX := INTER7.INTEGER_ARRAY;
  13002.         TIDD := INTER0.INTEGER_ARRAY;
  13003.     end ADA_DADD;
  13004.  
  13005.     procedure ADA_DAMSG  (INPLIN : STRING;
  13006.                           INPLEN : in out INTEGER;
  13007.                           MAXLEN : INTEGER;
  13008.                           RTN    : out INTEGER) is
  13009.         INTER : F77_ACCESS.INTER_TYPE (N => (3 + INPLIN'LENGTH)/4);
  13010.     begin
  13011.         INTER.INTEGER_ARRAY := CONVERSION.F77_STRING (INPLIN);
  13012.         F77_ACCESS.ADAMSG (INTER, INPLEN, MAXLEN, RTN);
  13013.     end ADA_DAMSG;
  13014.     procedure ADA_DELETT (DESCR : INTEGER;
  13015.                           TIDD  : in out TIDD_TYPE;
  13016.                           RTN   : out INTEGER) is
  13017.         INTER : F77_ACCESS.INTER_TYPE (N => 3);
  13018.     begin
  13019.         INTER.INTEGER_ARRAY := TIDD;
  13020.         F77_ACCESS.ADELETT (DESCR, INTER, RTN);
  13021.         TIDD := INTER.INTEGER_ARRAY;
  13022.     end ADA_DELETT;
  13023.  
  13024.     procedure ADA_DFIND (DESCR  : INTEGER;
  13025.                          KYM0   : INTEGER;
  13026.                          KYIDX  : INTEGER_ARRAY_TYPE;
  13027.                          KYVAL0 : STRING;
  13028.                          KYTL   : INTEGER;
  13029.                          TIDD   : in out TIDD_TYPE;
  13030.                          IRD    : INTEGER;
  13031.                          RTN    : out INTEGER) is
  13032.         INTER1 : F77_ACCESS.INTER_TYPE (N => KYIDX'LENGTH);
  13033.         INTER2 : F77_ACCESS.INTER_TYPE (N => KYVAL0'LENGTH);
  13034.         INTER3 : F77_ACCESS.INTER_TYPE (N => 3);
  13035.     begin
  13036.         INTER1.INTEGER_ARRAY := KYIDX;
  13037.         INTER3.INTEGER_ARRAY := TIDD;
  13038.  
  13039.         for I in 1 .. INTER2.N loop
  13040.             INTER2.INTEGER_ARRAY (I) := CHARACTER'POS (KYVAL0 (I));
  13041.         end loop;
  13042.  
  13043.         F77_ACCESS.ADFIND (DESCR, KYM0, INTER1, INTER2, KYTL, INTER3, IRD, RTN);
  13044.         TIDD := INTER3.INTEGER_ARRAY;
  13045.     end ADA_DFIND;
  13046.  
  13047.     procedure ADA_DGINFO (DESCR               : INTEGER;
  13048.                           ATNAM               : in out STRING;
  13049.                           ATTL                : in out INTEGER;
  13050.                           ATIDX, ATLEN, ATTYP : out INTEGER_ARRAY_TYPE;
  13051.                           RTN                : out INTEGER) is
  13052.         INTER1 : F77_ACCESS.INTER_TYPE (N => ATNAM'LAST);
  13053.         INTER2 : F77_ACCESS.INTER_TYPE (N => ATIDX'LAST);
  13054.         INTER3 : F77_ACCESS.INTER_TYPE (N => ATLEN'LAST);
  13055.         INTER4 : F77_ACCESS.INTER_TYPE (N => ATTYP'LAST);
  13056.     begin
  13057.         for I in 1 .. INTER1.N loop
  13058.             INTER1.INTEGER_ARRAY (I) := CHARACTER'POS (ATNAM (I));
  13059.         end loop;
  13060.  
  13061.         F77_ACCESS.ADGINFO (DESCR, INTER1, ATTL, INTER2, INTER3, INTER4, RTN);
  13062.  
  13063.         for I in 1 .. INTER1.N loop
  13064.             ATNAM (I) := CHARACTER'VAL (INTER1.INTEGER_ARRAY (I));
  13065.         end loop;
  13066.  
  13067.         ATIDX := INTER2.INTEGER_ARRAY;
  13068.         ATLEN := INTER3.INTEGER_ARRAY;
  13069.         ATTYP := INTER4.INTEGER_ARRAY;
  13070.     end ADA_DGINFO;
  13071.     procedure ADA_DLOCK (RELIST : STRING;
  13072.                          MODLIS : INTEGER_ARRAY_TYPE;
  13073.                          LENL   : INTEGER;
  13074.                          RTN    : out INTEGER) is
  13075.         INTER1 : F77_ACCESS.INTER_TYPE (N => RELIST'LENGTH);
  13076.         INTER2 : F77_ACCESS.INTER_TYPE (N => MODLIS'LENGTH);
  13077.     begin
  13078.         for I in 1 .. INTER1.N loop
  13079.             INTER1.INTEGER_ARRAY (I) := CHARACTER'POS (RELIST (I));
  13080.         end loop;
  13081.         INTER2.INTEGER_ARRAY := MODLIS;
  13082.  
  13083.         F77_ACCESS.ADLOCK (INTER1, INTER2, LENL, RTN);
  13084.     end ADA_DLOCK;
  13085.  
  13086.     procedure ADA_DOPENDB (DBNAME : STRING; RTN : out INTEGER) is
  13087.         INTER : F77_ACCESS.INTER_TYPE (N => DBNAME'LENGTH);
  13088.     begin
  13089.         for I in 1 .. INTER.N loop
  13090.             INTER.INTEGER_ARRAY (I) := CHARACTER'POS (DBNAME (I));
  13091.         end loop;
  13092.  
  13093.         F77_ACCESS.ADOPENDB (INTER, RTN);
  13094.     end ADA_DOPENDB;
  13095.  
  13096.     procedure ADA_DPREV (DESCR : INTEGER;
  13097.                          TIDD  : in out TIDD_TYPE;
  13098.                          RTN   : out INTEGER) is
  13099.         INTER : F77_ACCESS.INTER_TYPE (N => 3);
  13100.     begin
  13101.         INTER.INTEGER_ARRAY := TIDD;
  13102.         F77_ACCESS.ADPREV (DESCR, INTER, RTN);
  13103.         TIDD := INTER.INTEGER_ARRAY;
  13104.     end ADA_DPREV;
  13105.  
  13106.     procedure ADA_DUNLK is
  13107.     begin
  13108.         F77_ACCESS.ADUNLK;
  13109.     end ADA_DUNLK;
  13110.  
  13111.     procedure ADA_ENDDM is
  13112.     begin
  13113.         F77_ACCESS.AENDDM;
  13114.     end ADA_ENDDM;
  13115.  
  13116.     procedure ADA_FACSS (DESCR : INTEGER; ACSIFO : out INTEGER_ARRAY_TYPE) is
  13117.         INTER : F77_ACCESS.INTER_TYPE (N => ACSIFO'LENGTH);
  13118.     begin
  13119.         F77_ACCESS.AFACSS (DESCR, INTER);
  13120.         ACSIFO := INTER.INTEGER_ARRAY;
  13121.     end ADA_FACSS;
  13122.     procedure ADA_GETA (DESCR  : INTEGER;
  13123.                         ATTINX : INTEGER;
  13124.                         VALUE  : out INTEGER_ARRAY_TYPE;
  13125.                         LENR   : out INTEGER;
  13126.                         FTYP   : out INTEGER;
  13127.                         RTN    : out INTEGER) is
  13128.         INTER : F77_ACCESS.INTER_TYPE (N => VALUE'LAST);
  13129.     begin
  13130.         F77_ACCESS.AGETA (DESCR, ATTINX, INTER, LENR, FTYP, RTN);
  13131.  
  13132.         VALUE := INTER.INTEGER_ARRAY;
  13133.     end ADA_GETA;
  13134.  
  13135.     procedure ADA_GETT (DESCR : INTEGER;
  13136.                         TIDD  : in out TIDD_TYPE;
  13137.                         RTN   : out INTEGER) is
  13138.         INTER : F77_ACCESS.INTER_TYPE (N => 3);
  13139.     begin
  13140.         INTER.INTEGER_ARRAY := TIDD;
  13141.         F77_ACCESS.AGETT (DESCR, INTER, RTN);
  13142.         TIDD := INTER.INTEGER_ARRAY;
  13143.     end ADA_GETT;
  13144.  
  13145.     procedure ADA_GETTB (DESCR  : INTEGER;
  13146.                          SINK   : out INTEGER_ARRAY_TYPE;
  13147.                          SINKLN : INTEGER) is
  13148.         INTER : F77_ACCESS.INTER_TYPE (N => SINK'LAST);
  13149.     begin
  13150.         F77_ACCESS.AGETTB (DESCR, INTER, SINKLN);
  13151.  
  13152.         SINK := INTER.INTEGER_ARRAY;
  13153.     end ADA_GETTB;
  13154.  
  13155.  
  13156.     procedure ADA_INSRTT (DESCR : INTEGER;
  13157.                           TIDD  : in out TIDD_TYPE;
  13158.                           RTN   : out INTEGER) is
  13159.         INTER : F77_ACCESS.INTER_TYPE (N => 3);
  13160.     begin
  13161.         INTER.INTEGER_ARRAY := TIDD;
  13162.         F77_ACCESS.AINSRTT (DESCR, INTER, RTN);
  13163.         TIDD := INTER.INTEGER_ARRAY;
  13164.     end ADA_INSRTT;
  13165.  
  13166. --  procedure ADA_INSRT2 (DESCR : INTEGER;
  13167. --                        TIDD  : in out TIDD_TYPE;
  13168. --                        RTN   : out INTEGER) is
  13169. --      INTER : F77_ACCESS.INTER_TYPE (N => 3);
  13170. --  begin
  13171. --      INTER.INTEGER_ARRAY := TIDD;
  13172. --      F77_ACCESS.AINSRT2 (DESCR, INTER, RTN);
  13173. --      TIDD := INTER.INTEGER_ARRAY;
  13174. --  end ADA_INSRT2;
  13175.  
  13176.  
  13177.     procedure ADA_IRELC (RELNAM : STRING;
  13178.                          RCKEY  : out INTEGER;
  13179.                          PERM   : INTEGER) is
  13180.         INTER : F77_ACCESS.INTER_TYPE (N => 3);
  13181.     begin
  13182.         INTER.INTEGER_ARRAY := CONVERSION.F77_STRING(RELNAM (1 .. 10)&"  ");
  13183.         F77_ACCESS.AIRELC (INTER, RCKEY, PERM);
  13184.     end ADA_IRELC;
  13185.     procedure ADA_LEXINT is
  13186.     begin
  13187.         F77_ACCESS.ALEXINT;
  13188.     end ADA_LEXINT;
  13189.  
  13190.     procedure ADA_MSGTTY (MSG    : STRING;
  13191.                           MSGLEN : INTEGER) is
  13192.         INTER : F77_ACCESS.INTER_TYPE (N => (MSG'LENGTH + 3) / 4);
  13193.     begin
  13194.         INTER.INTEGER_ARRAY := CONVERSION.F77_STRING(MSG);
  13195.         F77_ACCESS.AMSGTTY (INTER, MSGLEN);
  13196.     end ADA_MSGTTY;
  13197.  
  13198.     function ADA_NUMTUP (DESCR : INTEGER) return INTEGER is
  13199.         RESULT : INTEGER;
  13200.     begin
  13201.         F77_ACCESS.ANUMTUP (DESCR, RESULT);
  13202.         return RESULT;
  13203.     end ADA_NUMTUP;
  13204.  
  13205.     procedure ADA_OPENR (RELNAM : STRING;
  13206.                          DESCR  : out INTEGER;
  13207.                          RTN    : out INTEGER) is
  13208.         INTER : F77_ACCESS.INTER_TYPE (N => 3);
  13209.     begin
  13210.         INTER.INTEGER_ARRAY := CONVERSION.F77_STRING(RELNAM (1 .. 10)&"  ");
  13211.         F77_ACCESS.AOPENR (INTER, DESCR, RTN);
  13212.     end ADA_OPENR;
  13213.  
  13214.     procedure ADA_PARSLP  (RTN : out INTEGER) is
  13215.     begin
  13216.         F77_ACCESS.APARSLP (RTN);
  13217.     end ADA_PARSLP;
  13218.  
  13219.     procedure ADA_PUTA (DESCR  : INTEGER;
  13220.                         ATTINX : INTEGER;
  13221.                         VALUE  : INTEGER_ARRAY_TYPE;
  13222.                         LENGTH : INTEGER;
  13223.                         RTN    : out INTEGER) is
  13224.         INTER : F77_ACCESS.INTER_TYPE (N => VALUE'LAST);
  13225.     begin
  13226.         INTER.INTEGER_ARRAY := VALUE;
  13227.  
  13228.         F77_ACCESS.APUTA (DESCR, ATTINX, INTER, LENGTH, RTN);
  13229.     end ADA_PUTA;
  13230.  
  13231.  
  13232.     procedure ADA_PUTTB (DESCR  : INTEGER;
  13233.                          SOURCE : INTEGER_ARRAY_TYPE;
  13234.                          TUPLEN : INTEGER) is
  13235.         INTER : F77_ACCESS.INTER_TYPE (N => SOURCE'LAST);
  13236.     begin
  13237.         INTER.INTEGER_ARRAY := SOURCE;
  13238.  
  13239.         F77_ACCESS.APUTTB (DESCR, INTER, TUPLEN);
  13240.     end ADA_PUTTB;
  13241.     procedure ADA_RELLK (OPDB : STRING) is
  13242.         INTER : F77_ACCESS.INTER_TYPE (N => 3);
  13243.     begin
  13244.         INTER.INTEGER_ARRAY := CONVERSION.F77_STRING(OPDB (1 .. 10)&"  ");
  13245.         F77_ACCESS.ARELLK (INTER);
  13246.     end ADA_RELLK;
  13247.  
  13248.     procedure ADA_REPLAT (DESCR : INTEGER;
  13249.                           TIDD  : in out TIDD_TYPE;
  13250.                           RTN   : out INTEGER) is
  13251.         INTER : F77_ACCESS.INTER_TYPE (N => 3);
  13252.     begin
  13253.         INTER.INTEGER_ARRAY := TIDD;
  13254.         F77_ACCESS.AREPLAT (DESCR, INTER, RTN);
  13255.         TIDD := INTER.INTEGER_ARRAY;
  13256.     end ADA_REPLAT;
  13257.  
  13258.     procedure ADA_SETGET (DESCR      : INTEGER;
  13259.                           SETYPE     : INTEGER;
  13260.                           ARG3, ARG4 : TIDD_TYPE;
  13261.                           RTN        : out INTEGER) is
  13262.         INTER1 : F77_ACCESS.INTER_TYPE (N => 3);
  13263.         INTER2 : F77_ACCESS.INTER_TYPE (N => 3);
  13264.     begin
  13265.         INTER1.INTEGER_ARRAY := ARG3;
  13266.         INTER2.INTEGER_ARRAY := ARG4;
  13267.         F77_ACCESS.ASETGET (DESCR, SETYPE, INTER1, INTER2, RTN);
  13268.     end ADA_SETGET;
  13269.  
  13270.     procedure ADA_SETLK (OPDB : STRING) is
  13271.         INTER : F77_ACCESS.INTER_TYPE (N => 3);
  13272.     begin
  13273.         INTER.INTEGER_ARRAY := CONVERSION.F77_STRING(OPDB (1 .. 10)&"  ");
  13274.         F77_ACCESS.ASETLK (INTER);
  13275.     end ADA_SETLK;
  13276.  
  13277.     procedure ADA_SRCHA (DESCR : INTEGER;
  13278.                          ATNAM : STRING;
  13279.                          ATIDX : out INTEGER) is
  13280.         INTER : F77_ACCESS.INTER_TYPE (N => 3);
  13281.     begin
  13282.         INTER.INTEGER_ARRAY := CONVERSION.F77_STRING(ATNAM (1 .. 10)&"  ");
  13283.         F77_ACCESS.ASRCHA (DESCR, INTER, ATIDX);
  13284.     end ADA_SRCHA;
  13285.  
  13286.     procedure ADA_STARTDM is
  13287.     begin
  13288.         F77_ACCESS.ASTARTDM;
  13289.     end ADA_STARTDM;
  13290.  
  13291.     procedure ADA_TRELC (RCKEY : INTEGER;
  13292.                          HOW   : INTEGER;
  13293.                          NOPGS : INTEGER;
  13294.                          PGSZ  : INTEGER;
  13295.                          RTN   : out INTEGER) is
  13296.     begin
  13297.         F77_ACCESS.ATRELC (RCKEY, HOW, NOPGS, PGSZ, RTN);
  13298.     end ADA_TRELC;
  13299. end F77_CALLABLES;
  13300. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  13301. --damestest.txt
  13302. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  13303. with TEXT_IO;
  13304. use TEXT_IO;
  13305. with TOOLS;
  13306. use TOOLS;
  13307. with WAREHOUSE;
  13308. use WAREHOUSE;
  13309. with DISPLAY;
  13310. use DISPLAY;
  13311. with BOTH_VARIABLES;
  13312. use BOTH_VARIABLES;
  13313. with TTY_IO;
  13314.  
  13315. procedure DAMES_TEST is
  13316.  
  13317. --***************************************************************************--
  13318. --                          INTERNAL PROCEDURES                              --
  13319. --***************************************************************************--
  13320.  
  13321.  
  13322. -------------------------------------------------------------------------------
  13323. --                          procedure MENU_1                                 --
  13324. -------------------------------------------------------------------------------
  13325.     procedure MENU_1 is
  13326.     begin
  13327.     NEW_PAGE;
  13328.     DISPL (20, 04, "          MENU_1                                 ");
  13329.     DISPL (20, 07, "- End                                            ");
  13330.     DISPL (20, 08, "- Test all the procedures                        ");
  13331.     DISPL (20, 09, "- Test one procedure                             ");
  13332.     DISPL (20, 10, "- Log file display                               ");
  13333.     DISPL (20, 11, "- Files initialization                           ");
  13334.     DISPL (10, 14, "Put the cursor on your choice with ""NEW LINE"" ");
  13335.     DISPL (10, 15, "and then validate with ""CR"" ");
  13336.     end MENU_1;
  13337. -------------------------------------------------------------------------------
  13338. --                          procedure MENU_2                                 --
  13339. -------------------------------------------------------------------------------
  13340.     procedure MENU_2 is
  13341.     begin
  13342.     NEW_PAGE;
  13343.     DISPL (00, 01, "              MENU_2         ");
  13344.     NEW_LINE;
  13345.     PUT_LINE (" - MENU_1                                                        ");
  13346.     PUT_LINE (" DAMES_OPEN,           DAMES_EXECUTE,        DAMES_CLOSE,        ");
  13347.     PUT_LINE (" LL_D_OPEN,            LL_D_DEFINE_TABLE,    LL_D_LOCK,          ");
  13348.     PUT_LINE (" LL_D_GET_INFORMATION, LL_D_UNLOCK,          LL_D_CLOSE,         ");
  13349.     PUT_LINE (" LL_D_E_MATCH,         LL_D_F_MATCH,         LL_D_I_MATCH,       ");
  13350.     PUT_LINE (" LL_D_R_MATCH,         LL_D_S_MATCH,         LL_D_E_OR_MATCH,    ");
  13351.     PUT_LINE (" LL_D_F_OR_MATCH,      LL_D_I_OR_MATCH,      LL_D_R_OR_MATCH,    ");
  13352.     PUT_LINE (" LL_D_S_OR_MATCH,      LL_D_E_AND_MATCH,     LL_D_F_AND_MATCH,   ");
  13353.     PUT_LINE (" LL_D_I_AND_MATCH,     LL_D_R_AND_MATCH,     LL_D_S_AND_MATCH,   ");
  13354.     PUT_LINE (" LL_D_FIND,            LL_D_FIND_NEXT,       LL_D_FIND_PREVIOUS, ");
  13355.     PUT_LINE (" LL_D_NEXT,            LL_D_PREVIOUS,        LL_D_E_GET_COLUMN,  ");
  13356.     PUT_LINE (" LL_D_F_GET_COLUMN,    LL_D_I_GET_COLUMN,    LL_D_R_GET_COLUMN,  ");
  13357.     PUT_LINE (" LL_D_S_GET_COLUMN,    LL_D_E_GET_ROW,       LL_D_F_GET_ROW,     ");
  13358.     PUT_LINE (" LL_D_I_GET_ROW,       LL_D_R_GET_ROW,       LL_D_S_GET_ROW,     ");
  13359.     PUT_LINE (" LL_D_E_BUILD_COLUMN,  LL_D_F_BUILD_COLUMN,  LL_D_I_BUILD_COLUMN,");
  13360.     PUT_LINE (" LL_D_R_BUILD_COLUMN,  LL_D_S_BUILD_COLUMN,  LL_D_E_BUILD_ROW,   ");
  13361.     PUT_LINE (" LL_D_F_BUILD_ROW,     LL_D_I_BUILD_ROW,     LL_D_R_BUILD_ROW,   ");
  13362.     PUT_LINE (" LL_D_S_BUILD_ROW,     LL_D_UPDATE,          LL_D_INSERT,        ");
  13363.     PUT_LINE (" LL_D_DELETE);                                                   ");
  13364.     DISPL (0, 22,
  13365.            "Put the cursor on your choice with ""NEW LINE"" and ""ESC"" ");
  13366.     DISPL (0, 23, "and then validate with ""CR"" ");
  13367.     end MENU_2;
  13368.  
  13369. -------------------------------------------------------------------------------
  13370. --                          procedure MENU_3                                 --
  13371. -------------------------------------------------------------------------------
  13372.     procedure MENU_3 is
  13373.     begin
  13374.     DISPL (00, 04, "          MENU_3                                 ");
  13375.     DISPL (00, 06, "        - menu_1                                 ");
  13376.     DISPL (00, 07, "        - menu_2                                 ");
  13377.     DISPL (00, 08, "        - execute                                ");
  13378.     DISPL (00, 09, "        - create                                 ");
  13379.     DISPL (00, 10, "        - modify                                 ");
  13380.     DISPL (00, 11, "        - delete                                 ");
  13381.     DISPL (00, 15, "  put the cursor on your choice with ""NEW LINE""  ");
  13382.     DISPL (00, 16, "  and then validate with ""CR""                     ");
  13383.     end MENU_3;
  13384. --***************************************************************************--
  13385. --                          procedure BODY                                   --
  13386. --***************************************************************************--
  13387.  
  13388. begin
  13389.  
  13390. -- ROLM bugs >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  13391.     ACC_LIST (49, 01) := 25;
  13392.     ACC_LIST (49, 02) := 14;
  13393.     ACC_LIST (49, 03) := 15;
  13394. -- end ROLM bugs >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  13395.  
  13396.     CREATE (FILE => LOG_FILE, NAME => "log_file");
  13397.  
  13398.     loop
  13399.     MENU_1;
  13400.     loop
  13401.         ROW := 7;
  13402.         COLUMN := 20;
  13403.         CHOICE (R_O_W, 11, ROW, COLUMN);
  13404.         if ROW <= 11 then  exit;  end if;
  13405.     end loop;
  13406.  
  13407.     NEW_PAGE;
  13408.  
  13409.     case ROW is
  13410.         when 8 => 
  13411.         EXECUTE_AUTOMATIC_VERSION;
  13412.         when 9 => 
  13413.         MENU2:
  13414.         loop
  13415.             MENU_2;
  13416. -- cursor movement >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  13417.             TTY_IO.ECHO_OFF;
  13418.             COLUMN := 1;
  13419.             ROW := 2;
  13420.             loop
  13421.             SCREEN_POS (COLUMN, ROW);
  13422.             TTY_IO.GET (A);
  13423.  
  13424.             case A is
  13425.                 when ASCII.CR =>  exit;
  13426.                 when ASCII.LF => 
  13427.                 ROW := ROW + 1;
  13428.                 if ROW > 20 then
  13429.                     ROW := 2;
  13430.                 end if;
  13431.                 when ASCII.ESC => 
  13432.                 COLUMN := COLUMN + 22;
  13433.                 if COLUMN > 45 then
  13434.                     COLUMN := 1;
  13435.                 end if;
  13436.                 when ASCII.DEL => 
  13437.                 COLUMN := COLUMN - 22;
  13438.                 if COLUMN < 1 then
  13439.                     COLUMN := 45;
  13440.                 end if;
  13441.                 when others =>  null;
  13442.             end case;
  13443.             end loop;
  13444.  
  13445.             TTY_IO.ECHO_ON;
  13446. -- end cursor movement >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  13447.             NEW_PAGE;
  13448.  
  13449.             if ROW /= 2 then
  13450.             case COLUMN is
  13451.                 when 1 => 
  13452.                 INTERFACE_NB :=
  13453.                   INTERFACE_NUMBER ((ROW - 3) * 3);
  13454.                 when 23 => 
  13455.                 INTERFACE_NB :=
  13456.                   INTERFACE_NUMBER ((ROW - 3) * 3 + 1);
  13457.                 when 45 => 
  13458.                 INTERFACE_NB :=
  13459.                   INTERFACE_NUMBER ((ROW - 3) * 3 + 2);
  13460.                 when others =>  null;
  13461.             end case;
  13462.  
  13463.             RDWR_POINTER_TABLE (LOAD);
  13464.             INTERFACE_PR_NAME :=
  13465.               INTERFACE_PROCEDURE_NAME'VAL (INTERFACE_NB);
  13466.  
  13467.             loop
  13468.                 PUT ("interface procedure " &
  13469.                  INTERFACE_PROCEDURE_NAME'IMAGE
  13470.                    (INTERFACE_PR_NAME));
  13471.  
  13472.                 MENU_3;
  13473.                 loop
  13474.                 ROW := 6;
  13475.                 COLUMN := 8;
  13476.                 CHOICE (R_O_W, 11, ROW, COLUMN);
  13477.                 if ROW <= 11 then  exit;  end if;
  13478.                 end loop;
  13479.  
  13480.                 NEW_PAGE;
  13481.  
  13482.                 case ROW is
  13483.  
  13484.                 when 6      =>  exit MENU2;
  13485.  
  13486.                 when 7      =>  exit;
  13487.  
  13488.                 when 8      =>  EXECUTE_TEST_CASE;
  13489.  
  13490.                 when 9      =>  CREATE_TEST_CASE;
  13491.  
  13492.                 when 10     =>  MODIFY_TEST_CASE;
  13493.  
  13494.                 when 11     =>  DELETE_TEST_CASE;
  13495.  
  13496.                 when others =>  null;
  13497.                 end case;
  13498.             end loop;
  13499.             else
  13500.             exit;
  13501.             end if;
  13502.         end loop MENU2;
  13503.  
  13504.         when 10 =>  INFORM_ABOUT_RESULT;
  13505.         when 11 => 
  13506.         DISPL (00, 3, "this is the procedure INITIALIZE.    ");
  13507.         DISPL (00, 4, "BE CARREFUL with this procedure :    ");
  13508.         DISPL (00, 5, "it initializes ALL the files.        ");
  13509.         DISPL (00, 7, "now,are you sure to go on (Y/N) ?    ");
  13510.  
  13511.         loop
  13512.             SCREEN_POS (34, 7);  GET (A);
  13513.             exit when A = 'Y' or A = 'N';
  13514.         end loop;
  13515.  
  13516.         NEW_PAGE;
  13517.  
  13518.         if A = 'Y' then
  13519.             DISPL (00, 1, "initialize");
  13520.             DISPL (30, 10, "WORKING , be quiet !");
  13521.             INITIALIZE;
  13522.         end if;
  13523.  
  13524.         when others =>  exit;
  13525.  
  13526.     end case;
  13527.  
  13528.     end loop;
  13529.  
  13530.     CLOSE (LOG_FILE);
  13531.  
  13532. end DAMES_TEST;
  13533. pragma MAIN;
  13534.  
  13535.