home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / news / 769 / s3lookup.prg < prev    next >
Text File  |  1993-09-17  |  3KB  |  94 lines

  1. #INCLUDE "INKEY.CH"
  2.  
  3. proc main
  4. local nChoice
  5. slsf_color("S3COLOR")
  6. initsup()
  7. setcolor(sls_normcol())
  8.  
  9. while .t.
  10.     nChoice := menu_v("Lookups:","In GETS","With Exception Block","Quit")
  11.     do case
  12.     case nChoice == 1
  13.       LOOKREAD()
  14.     case nChoice == 2
  15.       LOOKEXCEPT()
  16.     case nChoice == 3
  17.       exit
  18.     endcase
  19. end
  20.  
  21.  
  22. //--------------------------------------------------------------------------
  23. static proc lookexcept
  24. local bBlock := {|k|iif(k==K_ALT_E .or. k==K_ALT_A,GENED(k==K_ALT_A),nil)}
  25. field product
  26. aMsg({ "What we'll do here","is set up a call to SMALLS()", "which contains an",;
  27.        "exception block which calls GENED()","so that if ALT-A is pressed, a",;
  28.        "record is added","and if ALT-E is pressed","the record is edited."})
  29.  
  30. use S3PROD
  31.  
  32.  
  33. SMALLS({||product}, "Product" ,nil, nil, nil,nil,bBlock)
  34.  
  35. //Smalls(expDisplayString,[cTitle],[expAlias],[expReturn],;
  36. //                [expStartRange,expEndRange],[bException],[lForceCaps])
  37.  
  38. return
  39.  
  40.  
  41.  
  42. //--------------------------------------------------------------------------
  43. static proc lookread
  44. local cInscreen := savescreen(0,0,24,79)
  45. local mProduct1 := space(10)
  46. local mProduct2 := space(10)
  47. local mProduct3 := space(10)
  48. local mProduct4 := space(10)
  49. local mState    := space(2)
  50. memvar getlist
  51. field product, state
  52. select 1
  53. use S3PROD
  54. select 2
  55. use S3STATES
  56. SELECT 1
  57.  
  58. @ 0,0,24,79 BOX "┌─┐│┘─└│ "
  59. @ 1,4 SAY "Various lookup tables in GETs:"
  60. @ 5,25 SAY "Pressing F2 here does a lookup on S3PROD.DBF"
  61. @ 6,25 SAY "for PRODUCT - SMALLKSET()"
  62. @ 8,25 SAY "If this get is left empty, a lookup is done on"
  63. @ 9,25 SAY "S3PROD.DBF   - SMALLVALID()"
  64. @ 11,25 SAY "This get is handled by SMALLWHEN() - the get is"
  65. @ 12,25 SAY "never actually 'edited'"
  66. @ 14,25 SAY "Here a lookup is done in S3STATES.DBF to validate"
  67. @ 15,25 SAY "that this state IS IN that file - ISINLOOK()"
  68. @ 16,25 SAY "If it is not, a lookup table is presented."
  69. @ 18,25 SAY "Here, a lookup is done in S3PROD.DBF to validate"
  70. @ 19,25 SAY "that this product is NOT IN that file - ISNOTDUP()"
  71.  
  72. SMALLKSET(K_F2,"lookread","mproduct1",{||product},"Product",1,"PRODUCT")
  73.  
  74. @5,4 get mProduct1
  75. @8,4 get mProduct2 VALID smallvalid({||!empty(mProduct2)},;
  76.                          {||product},"Product",1,"PRODUCT")
  77. @11,4 get mProduct3 WHEN smallwhen(.f.,.f.,;
  78.                            {||product},"Product",1,"PRODUCT")
  79.  
  80. @14,4 get mState VALID ;
  81.   smallvalid({||ISINLOOK(mState,2,{||S3STATES->STATE},.F.,"Not a valid state")},;
  82.   {||state},"States",2,"state")
  83.  
  84. @18,4 get mProduct4 valid ISNOTDUP(mProduct4,nil,{||s3prod->product},;
  85.                           nil,nil,"Duplicate found")
  86. RAT_READ(getlist)
  87. ss_wipev(0,0,24,79,cInscreen)
  88. select 1
  89. use
  90. select 2
  91. use
  92. return
  93.  
  94.