home *** CD-ROM | disk | FTP | other *** search
/ Games 1995 to 2000 / Games.iso / SexTetris / RELATION.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-16  |  7.4 KB  |  196 lines

  1. /*****************************************************************************/
  2. /*  RELATION.C                                                                 */
  3. /*****************************************************************************/
  4. #include     "microlib.h"
  5.  
  6.  
  7. /*****************************************************************************/
  8. /* Function: int drel(int row, int col, D4DATA *db_master, char *fieldm      */
  9. /*                    D4DATA *db_slave, char* fields);                       */
  10. /* Description: Displays a relation on the current window.                   */
  11. /*              Master and slave files must be open.                         */
  12. /* Parameters: int row                                                       */
  13. /*             int col             -> Coordinates to display th relation.    */
  14. /*             D4DATA *db_master   -> Master file pointer.                   */
  15. /*             char *fieldm        -> Field Name of the master file.         */
  16. /*             D4DATA *db_slave    -> Slave  file pointer.                   */
  17. /*             char *fields        -> Field Name of the slave file.          */
  18. /* Returns: Nothing.                                                         */
  19. /* Uses: Nothing.                                                            */
  20. /*****************************************************************************/
  21. int drel(row, col, db_master, fieldm, db_slave, fields)
  22. int row;
  23. int col;
  24. D4DATA *db_master;
  25. D4DATA *db_slave;
  26. char *fieldm;
  27. char *fields;
  28. {
  29.     int surn_len;
  30.     int code_len;
  31.  
  32.     surn_len = f4len(d4field(db_slave,  fields));
  33.     code_len = f4len(d4field(db_master, fieldm));
  34.  
  35.     if(d4seek(db_slave, f4str(d4field(db_master, fieldm))) != 0) {
  36.         if(!memcmp(f4str(d4field(db_master, fieldm)), space(code_len), code_len)) {
  37.             w4num_att(row, col, space(surn_len), surn_len, custom[MAIN_I]);
  38.             }
  39.         else {
  40.             w4num_att(row, col, space(surn_len), surn_len, custom[MAIN_I]);
  41.             w4num_att(row, col, mes[ME+6], 10, custom[MAIN_I]);
  42.             }
  43.         }
  44.     else
  45.         w4num_att(row, col, f4str(d4field(db_slave, fields)), surn_len, custom[MAIN_I]);
  46.     d4unlock_index(db_slave);
  47.     }
  48.  
  49.  
  50. /*****************************************************************************/
  51. /* Function: int drel(int row, int col, D4DATA *db_master, char *fieldm      */
  52. /*                    D4DATA *db_slave, char* fields);                       */
  53. /* Description: Displays a relation on the current window with a specified   */
  54. /*              attribute. Master and slave files must be open.                  */
  55. /* Parameters: int row                                                       */
  56. /*             int col             -> Coordinates to display th relation.    */
  57. /*             D4DATA *db_master   -> Master file pointer.                   */
  58. /*             char *fieldm        -> Field Name of the master file.         */
  59. /*             D4DATA *db_slave    -> Slave  file pointer.                   */
  60. /*             char *fields        -> Field Name of the slave file.          */
  61. /*             int attribute          -> The attribute                          */
  62. /* Returns: Nothing.                                                         */
  63. /* Uses: Nothing.                                                            */
  64. /*****************************************************************************/
  65. int drel_att(row, col, db_master, fieldm, db_slave, fields, attribute)
  66. int row;
  67. int col;
  68. int attribute;
  69. D4DATA *db_master;
  70. D4DATA *db_slave;
  71. char *fieldm;
  72. char *fields;
  73. {
  74.     int surn_len;
  75.     int code_len;
  76.  
  77.     surn_len = f4len(d4field(db_slave,  fields));
  78.     code_len = f4len(d4field(db_master, fieldm));
  79.  
  80.     if(d4seek(db_slave, f4str(d4field(db_master, fieldm))) != 0) {
  81.         d4unlock_index(db_slave);
  82.         if(!memcmp(f4str(d4field(db_master, fieldm)), space(code_len), code_len)) {
  83.             w4num_att(row, col, space(surn_len), surn_len, attribute);
  84.             }
  85.         else {
  86.             w4num_att(row, col, space(surn_len), surn_len, attribute);
  87.             w4num_att(row, col, mes[ME+6], 10, attribute);
  88.             }
  89.         }
  90.     else
  91.         w4num_att(row, col, f4str(d4field(db_slave, fields)), surn_len, attribute);
  92.     d4unlock_index(db_slave);
  93.     }
  94.  
  95. /*****************************************************************************/
  96. /* Function: int drelnum_att(int row, int col, D4DATA *db_master, char *fieldm      */
  97. /*                    D4DATA *db_slave, char* fields, num, attribute);       */
  98. /* Description: Displays a relation on the current window with a specified   */
  99. /*              attribute. Master and slave files must be open.                  */
  100. /* Parameters: int row                                                       */
  101. /*             int col             -> Coordinates to display th relation.    */
  102. /*             D4DATA *db_master   -> Master file pointer.                   */
  103. /*             char *fieldm        -> Field Name of the master file.         */
  104. /*             D4DATA *db_slave    -> Slave  file pointer.                   */
  105. /*             char *fields        -> Field Name of the slave file.          */
  106. /*             int attribute          -> The attribute                          */
  107. /* Returns: Nothing.                                                         */
  108. /* Uses: Nothing.                                                            */
  109. /*****************************************************************************/
  110. int drelnum_att(row, col, db_master, fieldm, db_slave, fields, num, attribute)
  111. int row;
  112. int col;
  113. int attribute;
  114. int num;
  115. D4DATA *db_master;
  116. D4DATA *db_slave;
  117. char *fieldm;
  118. char *fields;
  119. {
  120.     int surn_len;
  121.     int code_len;
  122.     int numeric_flag;
  123.  
  124.     if(f4type(d4field(db_slave, fields)) == 'N')
  125.         numeric_flag = TRUE;
  126.     else
  127.         numeric_flag = FALSE;
  128.  
  129.     surn_len = f4len(d4field(db_slave,  fields));
  130.     code_len = f4len(d4field(db_master, fieldm));
  131.  
  132.     /* If not found */
  133.     if(d4seek(db_slave, f4str(d4field(db_master, fieldm))) != 0) {
  134.  
  135.         if(!memcmp(f4str(d4field(db_master, fieldm)), space(code_len), code_len)) {
  136.             w4num_att(row, col, space(surn_len), num, attribute);
  137.             }
  138.         else {
  139.             w4num_att(row, col, space(surn_len), surn_len, attribute);
  140.             w4num_att(row, col, mes[ME+6], 10, attribute);
  141.             }
  142.  
  143.         }
  144.     /* If found */
  145.     else {
  146.         if(numeric_flag) {
  147.             w4attribute(attribute);
  148.             w4int(row, col, f4int(d4field(db_slave, fields)), num);
  149.             }
  150.         else
  151.             w4num_att(row, col, f4str(d4field(db_slave, fields)), num, attribute);
  152.         }
  153.  
  154.     d4unlock_index(db_slave);
  155.     }
  156.  
  157. int dreltype_att(row, col, db_master, fieldm, db_slave, fields, attribute)
  158. int row;
  159. int col;
  160. int attribute;
  161. D4DATA *db_master;
  162. D4DATA *db_slave;
  163. char *fieldm;
  164. char *fields;
  165. {
  166.     int code_len;
  167.     int surn_len;
  168.  
  169.     code_len = f4len(d4field(db_master, fieldm));
  170.     surn_len = 10;
  171.  
  172.     /* If not found */
  173.     if(d4seek(db_slave, f4str(d4field(db_master, fieldm))) != 0) {
  174.  
  175.         if(!memcmp(f4str(d4field(db_master, fieldm)), space(code_len), code_len)) {
  176.             w4num_att(row, col, space(surn_len), surn_len, attribute);
  177.             }
  178.         else {
  179.             w4num_att(row, col, space(surn_len), surn_len, attribute);
  180.             w4num_att(row, col, mes[ME+6], 10, attribute);
  181.             }
  182.  
  183.         }
  184.     /* If found */
  185.     else {
  186.         if(!memcmp(f4str(d4field(db_slave, fields)), "C", 1))
  187.             w4num_att(row, col, "ëäêïäîÄ   ", 10, attribute);
  188.         else if(!memcmp(f4str(d4field(db_slave, fields)), "N", 1))
  189.             w4num_att(row, col, "ÇÉêçïåÆêëÄ", 10, attribute);
  190.         else if(!memcmp(f4str(d4field(db_slave, fields)), "D", 1))
  191.             w4num_att(row, col, "åïäÉÄïåîêÇ", 10, attribute);
  192.         }
  193.  
  194.     d4unlock_index(db_slave);
  195.     }
  196.