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

  1. *****************************************************************
  2. * Test program for CHKKEY functions -  FILE T_CHKKEY.PRG
  3. *****************************************************************
  4.  
  5. * Copyright(c) 1991 -- James Occhiogrosso
  6.  
  7. # include "inkey.ch"
  8.  
  9. PRIVATE morderno := 0
  10.  
  11. * Initialize global colors and clear screen
  12. INITGLOBAL()
  13. SETCOLOR(colstd)
  14. CLEAR
  15.  
  16. * Open the test files and set relationship
  17.  
  18. USE customer INDEX customer NEW
  19. USE orders INDEX orders NEW
  20. SET RELATION TO custid INTO customer
  21.  
  22. DO WHILE LASTKEY() != K_ESC    // Exit on ESC key.
  23.  
  24.     * If the order number exists,  CHKKEY displays the company
  25.     * from customer. Uses ORDER_INFO optionally to display
  26.     * other related items or perform computations.
  27.  
  28.     @ 5, 3 SAY 'Order No: ' GET morderno PICTURE "999999" ;
  29.            VALID CHKKEY("orders","morderno","order_info", ;
  30.                         5, 30, 70, "customer->company",   ;
  31.                         "customer->custid", ' - ')
  32.  
  33.     READ
  34. ENDDO
  35.  
  36. RETURN
  37.  
  38. *****************************************************************
  39. FUNCTION ORDER_INFO
  40. *****************************************************************
  41. *
  42. * This is a simple UDF for CHKKEY. If it finds the order number,
  43. * it displays corresponding data from the order file. Otherwise,
  44. * it clears the associated screen area.
  45.  
  46. LOCAL oldcolor := SETCOLOR(colhelp1)
  47.  
  48. IF FOUND()
  49.     @ 6, 30 SAY 'Part number: ' + orders->partno
  50.     @ 7, 30 SAY 'Price: $ ' + LTRIM(STR(orders->price))
  51. ELSE
  52.     @ 6, 30 CLEAR TO 7, 70
  53. ENDIF
  54.  
  55. * Note that CHKKEY's return value can be altered if desired
  56. SETCOLOR(oldcolor)
  57. RETURN FOUND()
  58.  
  59.