home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SAMPLES.EXE / T_DBVIEW.PRG < prev    next >
Encoding:
Text File  |  1991-01-25  |  2.5 KB  |  94 lines

  1. *****************************************************************
  2. * Test program for DBVIEW function -  FILE T_DBVIEW.PRG
  3. *****************************************************************
  4.  
  5. * Copyright(c) 1991 -- James Occhiogrosso
  6.  
  7. * Displays a window of customer records if entered
  8. * account ID is not found in customer database.
  9.  
  10. # include "inkey.ch"
  11. # include "box.ch"
  12.  
  13. * Force linking of DBVIEW function
  14. EXTERNAL DBVIEW
  15.  
  16. PRIVATE mcustid := SPACE(6), address1 := SPACE(30)
  17.  
  18. INITGLOBAL()
  19. SETCOLOR(colstd)
  20. CLEAR
  21.  
  22. * Set SOFTSEEK on to prevent the window
  23. * from starting at the end of the file.
  24. SET SOFTSEEK ON
  25.  
  26. * Open the test files and set relationship
  27.  
  28. USE customer INDEX customer NEW
  29. USE orders INDEX orders NEW
  30. SET RELATION TO custid INTO customer
  31.  
  32. DO WHILE LASTKEY() <> K_ESC
  33.  
  34.     @ 5, 12 GET mcustid PICTURE "!!!999" ;
  35.                 VALID CHKKEY("customer", "mcustid", "custview", ;
  36.                              5, 20, 50, "company")
  37.  
  38.     @ 7, 12 GET address1
  39.  
  40.     READ
  41. ENDDO
  42.  
  43. RETURN
  44.  
  45.  
  46. *****************************************************************
  47. FUNCTION CUSTVIEW
  48. *****************************************************************
  49.  
  50. * Note that on entry to this procedure from CHKKEY, the FOUND() 
  51. * status is not altered. We use it here to determine if we need
  52. * to display the customer window.
  53. *
  54.  
  55. LOCAL dbe_view := ARRAY(1), headings := old_color := ;
  56.       old_screen := '', old_record := RECNO()
  57.  
  58. IF .NOT. FOUND()
  59.  
  60.     * Save screen values
  61.     old_color  := SETCOLOR(colwindow)
  62.     old_screen := SCRNSAVE(7, 29, 19, 75)
  63.  
  64.     * Box window and set up DBEDIT view
  65.     @ 7, 29, 19, 75 BOX B_SINGLE + ' '
  66.     dbe_view[1] = '" " + custid + "  │  " + company + " "'
  67.     headings := 'Cust. ID            Company Name'
  68.  
  69.     * Call DBEDIT using DBVIEW to handle messages
  70.     DBEDIT( 8, 31, 18, 73, dbe_view, 'dbview', '', headings)
  71.  
  72.     * Return selection to mcustid variable
  73.     mcustid = custid
  74.  
  75.     * Restore screen
  76.     SETCOLOR(old_color)
  77.     SCRNREST(old_screen)
  78.  
  79.     * Return to original Customer record. The cursor is on 
  80.     * custid GET as if this procedure never executed. An Enter
  81.     * is placed in the keyboard so that when CUSTVIEW returns,
  82.     * CHKKEY is called again. The cycle repeats and since the
  83.     * the customer ID is now valid, CHKKEY displays the customer
  84.     * name. When CUSTVIEW is called for the second time it simply
  85.     * returns immediately. Thus, both an account number and name
  86.     * are displayed.
  87.  
  88.     GOTO old_record
  89.     KEYBOARD CHR(K_ENTER)
  90. ENDIF
  91.  
  92. RETURN FOUND()
  93.  
  94.