home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / EXAMPLES / N4PULL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-03  |  2.2 KB  |  106 lines

  1.  
  2. /*  n4pull.c  (c)Copyright Sequiter Software Inc., 1987, 1988, 1989. All rights reserved. 
  3.  
  4.     This is the example from routine 'n4pull_down' in the manual.
  5. */
  6.  
  7. #include "d4base.h"
  8. #include "w4.h"
  9.  
  10. static int  do_command( int ) ;
  11. static int  do_display( int ) ;
  12.  
  13. main()
  14. {
  15.    int  horizontal_ref, sub_one, sub_two ;
  16.    char no_flds[8] ;
  17.  
  18.    d4init() ;
  19.    w4clear(-1) ;
  20.  
  21.    /*  Open the database */
  22.    if ( d4use( "TEST.DBF" ) <  0 )
  23.    {
  24.       w4display( "Create a TEST.DBF data file before running this program.", (char *) 0 ) ;
  25.       w4exit(1) ;
  26.    }
  27.  
  28.    /*  Calculate some display information */
  29.    c4ltoa( (long) f4num_fields(), no_flds, 6 ) ;
  30.    no_flds[6] =  '\0' ;
  31.  
  32.    /*  Define the horizontal menu bar */
  33.    horizontal_ref =  w4define( -1,-1,-1,-1 ) ;
  34.  
  35.    /*  Define the main menu items */
  36.    n4( "Position Database" ) ;
  37.    n4reaction( n4sub_menu ) ;
  38.    n4ptr_save( &sub_one ) ;
  39.  
  40.    n4( "Display" ) ;
  41.    n4reaction( n4sub_menu ) ;
  42.    n4ptr_save( &sub_two ) ;
  43.  
  44.    /*  Define the 'Position Database' sub-menu */
  45.    sub_one =  w4define( -1,-1,-1,-1 ) ;
  46.    n4( "First Record" ) ;
  47.    n4action( do_command ) ;
  48.  
  49.    n4( "Last Record" ) ;
  50.    n4action( do_command ) ;
  51.  
  52.    n4( "Next Record" ) ;
  53.    n4action( do_command ) ;
  54.  
  55.    /*  Define the 'Display' sub-menu  */
  56.    sub_two =  w4define( -1,-1,-1,-1 ) ;
  57.  
  58.    n4( "Database Record" ) ;
  59.    n4action( do_display ) ;
  60.    n4ptr_save( f4record() ) ;
  61.  
  62.    n4( "Number of Fields" ) ;
  63.    n4action( do_display ) ;
  64.    n4ptr_save( no_flds ) ;
  65.  
  66.    /*  Turn the menus into a pulldown menu. */
  67.    n4pulldown( horizontal_ref ) ;
  68.  
  69.    /* Activate the menuing pulldown system */
  70.    w4cursor( -1,-1 ) ;
  71.    n4activate( horizontal_ref ) ;
  72.    w4cursor( 23,0 ) ;
  73.  
  74.    w4close( horizontal_ref ) ;
  75.    w4close( sub_one ) ;
  76.    w4close( sub_two ) ;
  77.  
  78.    d4close_all() ;
  79.    w4exit(0) ;
  80. }
  81.  
  82. static int  do_command( int item_ref )
  83. {
  84.    switch( *n4item_text(item_ref) )
  85.    {
  86.       case 'F':
  87.          d4top() ;
  88.          break ;
  89.  
  90.       case 'L':
  91.          d4bottom() ;
  92.          break ;
  93.  
  94.       case 'N':
  95.          d4skip(1L) ;
  96.          break ;
  97.    }
  98.    return 0 ;
  99. }
  100.  
  101. static int  do_display( int item_ref )
  102. {
  103.    w4display( (char *) n4ptr_get(item_ref), (char *) 0 ) ;
  104.    return 0 ;
  105. }
  106.