home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR7
/
FOXTAILS.ZIP
/
PICKPOP.PRG
< prev
next >
Wrap
Text File
|
1992-06-13
|
4KB
|
113 lines
FUNCTION PICKPOP
PARAMETER Pname, db, tg, fld, exp, isfld, Stre
* Written by R.L. Coppedge
* Copyright 1991 dbF Software Productions
* By the way, dbF also has:
* SysTrak A Computer Hardware/Software Inventory System
* Flags A Flatfile Application Gen. for db3,4 and Fox
* ClasAdz A Classified/Notice system for Networks
* FerretPro A collection of FoxPro tools (like this one)
* Contact dbF for more information.
* dbF Software Productions
* P.O. Box 37194
* Cleve., Ohio 44137-0194
* CIS: 72117,165
* (216)491-4581
*
* This code may be modified, but leave this original notice up
* here intact, if ya don't mind. (Add your own comments about
* how much better you made it if you like)
* Passed Parameters:
* Pname is the name of the POPUP
* Db is the name of the database that the popup uses...
* Tg is the name of the CDX tag that the popup uses...
* Fld is the name of the field to be verified...
* Exp is the expression to be replaced from the POPUP.
* isfld: Logical-Is the expression to be validated a Field?
* Stre: Logical-Is this a variable STORE (as opposed to a GET?)
* Two things have to happen.
* 1 is that the popup Pname has to be defined, with the
* ON POPUP (Pname) DEACTIVATE POPUP Specified.
* 2 is that the PICKPOP has to have the parameters set up properly
* Failure to do these things cause other things to get screwed up...
* 1st we need to determine whether we're supposed to select
* another database/index combination to verify the information.
* If we are, we 1st need to save the current positioning of
* database, and index.
* CAUTION!! Using the same database for the popup as you are
* entering could make life interesting if you are editing
* actual db Fields...
Infld = EVALUATE(Fld)
Odb = ALIAS()
Orc = RECNO()
Otg = ORDER()
IF UPPER(Db) <> ALIAS() AND !EMPTY(Db) && New Database?
SELECT (Db)
ENDIF
IF UPPER(Tg) <> ORDER() AND !EMPTY(Tg) && New Index?
SET ORDER TO (Tg)
ENDIF
Ex = SET("EXACT") && Initialize what the old Exact, Near, Confirm
Nr = SET("NEAR")
Cf = SET("CONFIRM")
SET EXACT ON && So we can test current entry/bypass popup
SET NEAR OFF
SET CONFIRM ON
SEEK InFld && The hunt! The Hunt!!
IF !EOF() AND InFld == EVALUATE(Exp) && Evaluate...faster to run/slower
* Notice the double (==) equals...no approximates here, mate.
* Make things right in the world.
* This means that the initial value was a good one, and no further
* work needs done.
IF UPPER(Odb) <> ALIAS() AND !EMPTY(Odb)
SELECT (Odb)
ENDIF
IF UPPER(OTg) <> ORDER() AND !EMPTY(Tg)
SET ORDER TO (OTg)
ENDIF
SET NEAR &Nr.
SET EXACT &Ex.
SET CONFIRM &Cf.
IF Stre && We want to Store a value directly to a variable
RETURN EVALUATE(Exp)
ENDIF
RETURN .T. && Otherwise, just say it's ok.
ENDIF
SET NEAR ON
SEEK InFld && Best Guess, with Near on...
ACTIVATE POPUP (Pname)
SET NEAR &Nr.
SET EXACT &Ex.
SET CONFIRM &Cf.
IF Bar()=0 && The fink hit Escape...no Fair!
IF !Stre && It's a Get
RETURN .F. && That'll teach 'em!
ELSE
RETURN (Fld) && It's a Store, return unchanged value.
ENDIF
ENDIF
* If we are here, we have selected a record on the popup.
* If it's a STORE, Return the new value
* Else, if it's a field, REPLACE. Otherwise STORE the value
* appropriately, and return a .T.
IF UPPER(Odb) <> ALIAS() AND !EMPTY(Odb)
SELECT (Odb)
ENDIF
IF UPPER(OTg) <> ORDER() AND !EMPTY(Tg)
SET ORDER TO (OTg)
ENDIF
SET NEAR &Nr.
SET EXACT &Ex.
SET CONFIRM &Cf.
IF Stre
RETURN EVALUATE(Exp)
ENDIF
IF Isfld
REPLACE (Fld) WITH EVALUATE(Exp)
ELSE
STORE EVALUATE(Exp) TO (Fld)
ENDIF
SHOW GETS
RETURN .T.