home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR7 / FOXTAILS.ZIP / PICKPOP.PRG < prev    next >
Text File  |  1992-06-13  |  4KB  |  113 lines

  1. FUNCTION PICKPOP
  2. PARAMETER Pname, db, tg, fld, exp, isfld, Stre
  3. *    Written by R.L. Coppedge
  4. *    Copyright 1991 dbF Software Productions
  5. *    By the way, dbF also has:
  6. *    SysTrak        A Computer Hardware/Software Inventory System
  7. *    Flags        A Flatfile Application Gen. for db3,4 and Fox
  8. *    ClasAdz        A Classified/Notice system for Networks
  9. *    FerretPro    A collection of FoxPro tools (like this one)
  10. *    Contact dbF for more information.
  11. *    dbF Software Productions
  12. *    P.O. Box 37194
  13. *    Cleve., Ohio 44137-0194
  14. *    CIS: 72117,165
  15. *    (216)491-4581
  16. *
  17. *    This code may be modified, but leave this original notice up
  18. *    here intact, if ya don't mind.  (Add your own comments about
  19. *    how much better you made it if you like)
  20. *    Passed Parameters:
  21. *    Pname is the name of the POPUP
  22. *    Db is the name of the database that the popup uses...
  23. *    Tg is the name of the CDX tag that the popup uses...
  24. *    Fld is the name of the field to be verified...
  25. *    Exp is the expression to be replaced from the POPUP.
  26. *    isfld:    Logical-Is the expression to be validated a Field?
  27. *    Stre:    Logical-Is this a variable STORE (as opposed to a GET?)
  28.  
  29. *    Two things have to happen.
  30. *    1 is that the popup Pname has to be defined, with the
  31. *    ON POPUP (Pname) DEACTIVATE POPUP Specified.
  32. *    2 is that the PICKPOP has to have the parameters set up properly
  33. *    Failure to do these things cause other things to get screwed up...
  34. *    1st we need to determine whether we're supposed to select
  35. *    another database/index combination to verify the information.
  36. *    If we are, we 1st need to save the current positioning of
  37. *    database, and index.
  38. *    CAUTION!! Using the same database for the popup as you are
  39. *    entering could make life interesting if you are editing
  40. *    actual db Fields...
  41. Infld = EVALUATE(Fld)
  42. Odb = ALIAS()
  43. Orc = RECNO()
  44. Otg = ORDER()
  45. IF UPPER(Db) <> ALIAS() AND !EMPTY(Db)        &&    New Database?
  46.     SELECT (Db)
  47. ENDIF
  48. IF UPPER(Tg) <> ORDER() AND !EMPTY(Tg)        &&    New Index?
  49.      SET ORDER TO (Tg)
  50. ENDIF
  51. Ex = SET("EXACT")    &&    Initialize what the old Exact, Near, Confirm
  52. Nr = SET("NEAR")
  53. Cf = SET("CONFIRM")
  54. SET EXACT ON    &&    So we can test current entry/bypass popup
  55. SET NEAR OFF
  56. SET CONFIRM ON
  57. SEEK InFld    &&    The hunt!  The Hunt!!
  58. IF !EOF() AND InFld == EVALUATE(Exp)    &&    Evaluate...faster to run/slower
  59. *    Notice the double (==) equals...no approximates here, mate.
  60. *    Make things right in the world.
  61. *    This means that the initial value was a good one, and no further
  62. *    work needs done.
  63.     IF UPPER(Odb) <> ALIAS() AND !EMPTY(Odb)
  64.         SELECT (Odb)
  65.     ENDIF
  66.     IF UPPER(OTg) <> ORDER() AND !EMPTY(Tg)
  67.         SET ORDER TO (OTg)
  68.     ENDIF
  69.     SET NEAR &Nr.
  70.     SET EXACT &Ex.
  71.     SET CONFIRM &Cf.
  72.     IF Stre            &&    We want to Store a value directly to a variable
  73.         RETURN EVALUATE(Exp)
  74.     ENDIF
  75.     RETURN .T.    &&    Otherwise, just say it's ok.
  76. ENDIF
  77. SET NEAR ON
  78. SEEK InFld                &&    Best Guess, with Near on...
  79. ACTIVATE POPUP (Pname)
  80. SET NEAR &Nr.
  81. SET EXACT &Ex.
  82. SET CONFIRM &Cf.
  83. IF Bar()=0        &&    The fink hit Escape...no Fair!
  84.     IF !Stre        &&    It's a Get
  85.         RETURN .F.    &&    That'll teach 'em!
  86.     ELSE
  87.         RETURN (Fld)        &&    It's a Store, return unchanged value.
  88.     ENDIF
  89. ENDIF
  90. *    If we are here, we have selected a record on the popup.
  91. *    If it's a STORE, Return the new value
  92. *    Else, if it's a field, REPLACE.  Otherwise STORE the value
  93. *    appropriately, and return a .T.
  94. IF UPPER(Odb) <> ALIAS() AND !EMPTY(Odb)
  95.     SELECT (Odb)
  96. ENDIF
  97. IF UPPER(OTg) <> ORDER() AND !EMPTY(Tg)
  98.     SET ORDER TO (OTg)
  99. ENDIF
  100. SET NEAR &Nr.
  101. SET EXACT &Ex.
  102. SET CONFIRM &Cf.
  103. IF Stre
  104.     RETURN EVALUATE(Exp)
  105. ENDIF
  106. IF Isfld
  107.     REPLACE (Fld) WITH EVALUATE(Exp)
  108. ELSE
  109.     STORE EVALUATE(Exp) TO (Fld)
  110. ENDIF
  111. SHOW GETS
  112. RETURN .T.
  113.