home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / FOXPRO / TABLES / TBLDEMO.PRG < prev    next >
Text File  |  1992-12-03  |  6KB  |  188 lines

  1. * Program   :TblDemo.prg
  2. * Author    :Mark D. Miller
  3. * Date      :12-Nov-1992
  4. * Notice    : Copyright (c) 12-Nov-1992 by Mark D. Miller
  5. *             All Rights Reserved.
  6. * Notes     :Demo of the field table routines.
  7. *
  8. * The includes
  9. *
  10. #INCLUDE Table.hdr
  11. #INCLUDE IO.HDR
  12. #INCLUDE STRING.HDR
  13. #INCLUDE SYSTEM.HDR
  14. #INCLUDE KEYS.HDR
  15. #INCLUDE COLORS.HDR
  16. #INCLUDE DATABASE.HDR
  17. *
  18. * FORCE externs
  19. *
  20. VARDEF  EXTERN
  21.     BYTE        __color_std
  22.     BYTE        __color_enhcd
  23. ENDDEF
  24. *
  25. * Table Library externs
  26. *
  27. VARDEF  EXTERN
  28.     CHAR( 40 )      TblPath
  29. ENDDEF
  30. *
  31. * The database definition
  32. *
  33. DBFDEF Demo
  34.     CHAR( 20 )      Name
  35.     CHAR( 1 )       Sex
  36.     CHAR( 1 )       Eeoc
  37.     CHAR( 2 )       State
  38.     CHAR( 4 )       Program
  39. ENDDEF
  40.  
  41. VARDEF
  42.     CHAR( 20 )      Demo_Name
  43.     CHAR( 1 )       Demo_Sex
  44.     CHAR( 1 )       Demo_Eeoc
  45.     CHAR( 2 )       Demo_State
  46.     CHAR( 4 )       Demo_Program
  47. ENDDEF
  48.  
  49. INDEXDEF
  50.     CHAR( 20 )  DemoIdx UPPER( Demo->Name )
  51. ENDDEF
  52.  
  53. **********************************************************************
  54. *           T H E    C O D E                                         *
  55. **********************************************************************
  56. PROCEDURE Force_Main
  57.     VARDEF
  58.         UINT    ky
  59.     ENDDEF
  60.  
  61.     SET CONFIRM ON
  62.     *
  63.     * Set the path to the tables here
  64.     *
  65.     TblPath = "C:\FORCE\SOURCE\TABLE\"
  66.     *
  67.     * Establish aliases
  68.     *
  69.     SET ALIAS DemoIdx TO "TBLSAMP.FDX"
  70.     SET ALIAS Demo    TO "TBLSAMP.DBF"
  71.     *
  72.     * Open Files
  73.     *
  74.     OPEN "TBLSAMP" ALIAS Demo
  75.     IF .NOT. EXIST( "TBLSAMP.FDX" )
  76.         !Demo INDEX "TBLSAMP.FDX" ALIAS DemoIdx
  77.     ENDIF
  78.     *
  79.     * Draw the screen
  80.     *
  81.     __color_std = &blue_yellow
  82.     CLEAR
  83.     __color_std = &RED_WHITE
  84.     @  1, 26  SAY "Field Table Demo"
  85.     __color_std = &blue_yellow
  86.     @  3,  2  SAY "The routines function by trapping the TAB key on any of the four fields"
  87.     @  4,  2  SAY "below.  You set up the Field Tables at compile time and the actual table"
  88.     @  5,  2  SAY "data may be developed and modified at run-time."
  89.     @  7,  2  SAY "The only requirement to use these routines is: The GET variable must be a"
  90.     @  8,  2  SAY "GLOBAL CHAR of not more than 4 characters.  Note that here I show CHAR(1),"
  91.     @  9,  2  SAY "CHAR(2) and CHAR(4) vars."
  92.     @ 12, 16  SAY "See the file TABLE.DOC for more information."
  93.  
  94.     @ 15, 21  SAY "Name:"
  95.     @ 17,  3  SAY "Sex:"
  96.     @ 17, 21  SAY "Race:"
  97.     @ 17, 53  SAY "State:"
  98.     @ 19, 18  SAY "Program:"
  99.     *
  100.     * Draw f-keys on line 24 so we can show that errors save line 24
  101.     *
  102.     __color_std = &white_black
  103.     @ 24, 00  SAY CENTER( "Use These Keys: PgUp = Prev | PgDn = Next | ESC = Quit ", 80 )
  104.     __color_std = &blue_yellow
  105.     *
  106.     * Main Loop
  107.     *
  108.     DO WHILE .T.
  109.     *
  110.         * Load vars
  111.         *
  112.         Demo_Name   = Demo->Name
  113.         Demo_Sex    = Demo->Sex
  114.         Demo_Eeoc   = Demo->Eeoc
  115.         Demo_State  = Demo->State
  116.         Demo_Program= Demo->Program
  117.         *
  118.         * Show current table values
  119.         *
  120.         ShowTable( "SEX", 17, 10, 6, Demo_Sex )
  121.         ShowTable( "EEOC", 17, 29, 15, Demo_Eeoc )
  122.         ShowTable( "STATE", 17, 63, 15, Demo_State )
  123.         ShowTable( "PROGRAM", 19, 32, 30, Demo_Program )
  124.         @ 15, 27  GET  Demo_Name
  125.         @ 17,  8  GET  Demo_Sex PICTURE "!";
  126.                   FILTER Table( "SEX", 17, 10, 6, Demo_Sex ) ;
  127.                   VALID VerifyTable( "SEX", 17, 10, 6, Demo_Sex )
  128.         @ 17, 27  GET  Demo_Eeoc PICTURE "!";
  129.                   FILTER Table( "EEOC", 17, 29, 15, Demo_Eeoc ) ;
  130.                   VALID VerifyTable( "EEOC", 17, 29, 15, Demo_Eeoc )
  131.         @ 17, 60  GET  Demo_State PICTURE "!!";
  132.                   FILTER Table( "STATE", 17, 63, 15, Demo_State ) ;
  133.                   VALID VerifyTable( "STATE", 17, 63, 15, Demo_State )
  134.         @ 19, 27  GET  Demo_Program PICTURE "XXXX" ;
  135.                   FILTER Table( "PROGRAM", 19, 32, 30, Demo_Program ) ;
  136.                   VALID VerifyTable( "PROGRAM", 19, 32, 30, Demo_Program )
  137.         READ
  138.         !Demo REPLACE   Demo->Name WITH Demo_Name, ;
  139.                         Demo->Sex  WITH Demo_Sex,  ;
  140.                         Demo->Eeoc WITH Demo_Eeoc, ;
  141.                         Demo->State WITH Demo_State,    ;
  142.                         Demo->Program WITH Demo_Program
  143.  
  144.         ky = LASTKEY()
  145.         DO CASE
  146.             CASE ky = &K_ESC
  147.                 EXIT
  148.             CASE ky = &K_PG_UP
  149.                 !Demo SKIP -1
  150.                 IF A_BOF( Demo )
  151.                     !Demo GO TOP
  152.                     ??CHR( 7 )
  153.                 ENDIF
  154.             CASE ky = &K_PG_DOWN
  155.                 !Demo SKIP 1
  156.                 IF A_EOF( Demo )
  157.                     !Demo GO BOTTOM
  158.                     ??CHR( 7 )
  159.                 ENDIF
  160.             OTHERWISE
  161.         ENDCASE
  162.     ENDDO
  163.  
  164.     CLOSE Demo
  165.     *
  166.     * Closing comments
  167.     *
  168.     CLEAR
  169.     TEXT
  170.         Thank you for reviewing these routines.  Feel free to incorporate
  171.         these routines in your programs.  See the source for this program
  172.         for details.
  173.  
  174.         All I ask is if you find these routines helpful, please consider
  175.         making a contribution of $5.00 to:
  176.  
  177.                     Mark D. Miller
  178.                     612 Fairview Blvd. Apt. RNW
  179.                     Rockford, IL 61107
  180.                     71054,3103
  181.  
  182.     ENDTEXT
  183.     WAIT
  184.     __color_std = &black_light_grey
  185.     CLEAR
  186. ENDPRO
  187.  
  188. *  EOF : TblDemo.prg