home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
dbase
/
duflp
/
eds1.prg
< prev
next >
Wrap
Text File
|
1992-08-07
|
10KB
|
212 lines
FUNCTION SeeMatch
*-------------------------------------------------------------------------------
*-- Programmer..: Dan Madoni (Borland)
*-- Date........: 09/xx/1991
*-- Notes.......: Can be included in format screen to display an instant
*-- lookup match on a particular field. A shadowed box will
*-- appear with the matching value ... Taken from TECHNOTES.
*-- Written for.: dBASE IV, 1.1
*-- Rev. History: 06/12/1992 -- Minor -- added call to RECOLOR
*-- Calls.......: RECOLOR Procedure in PROC.PRG
*-- Called by...: None
*-- Usage.......: SeeMatch("<cFile>",<cSeekExp>,"<cReturn>",<nULRow>,<nULCol>,;
*-- <nBRRow>,<nBRCol>,"<cColor>)
*-- Example.....: SeeMatch("TRAVEL",LASTNAME,"TRAVELCODE",2,40,4,60,"w+/r")
*-- Returns.....: .t.
*-- Parameters..: cFile = Database alias in which lookup will be performed.
*-- -- this file must already be USEd in some area.
*-- cSeekExp = Expression which will be SEEKed.
*-- cReturn = Name of field to contain the 'return' value.
*-- nULRow = Upper Left Row for box
*-- nULCol = Upper Left Column for box
*-- nBRRow = Bottom Right Row
*-- nBRCol = Bottom Right Column
*-- cColor = Color of box
*-------------------------------------------------------------------------------
parameters cFile,cSeeExp,cReturn,nULRow,nULCol,nBRRow,nBRCol,cColor
private cRetVal, cAttr, cStartFile
*-- store starting position ...
cStartFile = alias()
select &cFile
*-- look for a matching expression
seek cSeekExp
if found()
cRetVal = &cReturn
else
cRetVal = "<Not Found>"
endif
*-- Store current color and draw a box
cAttr = set("ATTRIBUTES")
@nULRow+1,nULCol+1 fill to nBRRow+1,nBRCol+1 color w/n && shadow
set color to &cColor
@nULRow,nULCol clear to nBRRow,nBRCol && clear out area text will go in
@nULRow,nULCol To nBRRow,nBRCol && draw box
*-- display matching expresion, and return to initial area ...
@nULRow+1,nULCol+2 say cRetVal
do ReColor with cAttr
select cStartFile
RETURN .t.
*-- EoF: SeeMatch()
PROCEDURE FileMove
*-------------------------------------------------------------------------------
*-- Programmer..: David Frankenbach (FRNKNBCH)
*-- DF Software Development, Inc.
*-- PO Box 87
*-- Forest, VA, 24551
*-- (804) 237-2342
*-- Date........: 02/11/1992
*-- Notes.......: This procedure gives the record movement allowed with EDIT
*-- when you use a simple @SAY/GET..READ. It allows you to
*-- pre/post process each record during editing, something you
*-- can't do with EDIT. This works best with a single file,
*-- although it would work with a parent->child relation. You
*-- should: SELECT child and SET SKIP to child. This will
*-- allow the user to change the parent record pointer though!
*-- If you want to limit the child record movement to a single
*-- parent record, you can use a conditional index, or add logic
*-- to the routine to limit the record pointer movement. For these
*-- cases I have a seperate FileMove procedure, but they are not
*-- generic enough for public consumption.
*--
*-- These keys are trapped:
*-- UpArw, Shift-Tab, LeftArw, Ctrl-LeftArw, PgUp =
*-- backward one record
*-- DnArw, Tab, RightArw, Ctrl-RightArw, PgDn, Enter, Ctrl-End =
*-- forward one record
*-- Ctrl-PgUp = top of database or active index
*-- Ctrl-PgDn = bottom of database or active index
*-- Written for.: dBASE IV, 1.1
*-- Rev. History: 06/17/1991 - original routine.
*-- 02/07/1992 -- Ken Mayer, brought into one PROCEDURE,
*-- rather than a function and a procedure ...
*-- 02/11/1992 -- Author, additional documentation
*-- Released into Public Domain
*-- Calls.......: None
*-- Called by...: None
*-- Usage.......: do FileMove with <nKey>
*-- where: <nKey> is the return value of readkey()
*-- Example.....: lMove = .t. && if you want the user to be able to move the
*-- && record pointer in my applications if the user
*-- && is adding a new record I usually lMove = .f.,
*-- && for editing I allow them to move through the
*-- && records.
*-- lOk = .t.
*-- do while ( lOk )
*-- do Mem_Load && load memvars from record
*-- @say/gets && display/get the memvars
*-- read
*-- i = readkey() && grab last key ...
*-- lOk = ( i <> 27 ) && if Esc was pressed lOK is false
*-- if ( lOk )
*-- if ( i > 256 ) && if record is changed
*-- do Mem_Unload && replace dbf fields from memvars
*-- endif && ( i > 256 )
*-- if ( lMove ) && if ok to move record pointer
*-- do FileMove with i && <----- Move it
*-- else
*-- lOk = .f. && terminate loop if .not. lMove
*-- endif && ( lMove )
*-- endif && (lOK)
*-- enddo && while (lOK)
*-- Parameters..: nKey = last keystroke from a READKEY() call ...
*-- Returns.....: None
*-- Side Effects: Moves record pointer in current file if lMove = .t.
*-------------------------------------------------------------------------------
parameter nKey
private n
m->n = m->nKey
if ( m->n > 255 ) && if value is > 256, record has changed, but we want
m->n = m->n - 256 && values < 256 to figure out which direction to move
endif && from the readkey() table
do case
*-- keys to move backward through database 1 record at a time ...
*-- LeftArw, Ctrl-LeftArw, UpArw, Shift-Tab, PgUp
case ( m->n = 0 ) .or. ( m->n = 2 ) .or. ( m->n = 4 ) .or. ( m->n = 6 )
if ( .not. bof() ) && if not at beginning of file
skip -1 && move backward one record
endif
*-- keys to move forward through database 1 record at a time ...
*-- RightArw, Ctrl-RightArw, DownArw, Tab, PgDn, Ctrl-End, Enter
case ( m->n = 1 ) .or. ( m->n = 3 ) .or. ( m->n = 5 ) .or. ( m->n = 7 );
.or. ( m->n = 14) .or. ( m->n = 15)
if ( .not. eof() ) && if not end of file
skip 1 && move forward one record
endif
if ( eof() ) && if we're now at the EOF,
goto bottom && go back to last record ...
endif
*-- go to toP of database, Ctrl-PgUp
case ( m->n = 34 )
goto top
*-- go to BOTtoM of database, Ctrl-PgDn
case ( m->n = 35 )
goto bottom
endcase
RETURN
*-- EoP: FileMove
PROCEDURE DosShell
*-------------------------------------------------------------------------------
*-- Programmer..: Bowen Moursund
*-- Date........: 06-10-1992
*-- Notes.......: Swaps out dBASE from memory, loads a DOS shell
*-- Written for.: dBASE IV v1.5
*-- Rev. History: none
*-- Calls.......: None
*-- Called by...: Any
*-- Usage.......: do DosShell with <cAppName>
*-- Example.....: do DosShell with "MyApp"
*-- Parameters..: cAppName - the name of the application
*-------------------------------------------------------------------------------
parameter cAppName
private cDir, lCursOff, cBatFile, nFH, nResult
cAppName = iif(pcount() = 0, "the application", cAppName)
private all
cDir = set("directory")
lCursOff = ( set("cursor") = "OFF" )
cBatFile = tempname("bat") + ".bat"
nFH = fcreate(cBatFile)
if nFH > 0
nBytes = fputs(nFH,"echo off")
nBytes = fputs(nFH,"cls")
nBytes = fputs(nFH,"echo " + chr(255)) && echo a blank line
nBytes = fputs(nFH,"echo NOTE: Enter EXIT to resume " + cAppName + ".")
nBytes = fwrite(nFH,getenv("comspec"))
null = fclose(nFH)
set cursor on
nResult = run(.f., cBatFile, .t.)
if nResult # 0
run &cBatFile
endif
erase (cBatFile)
else
cComSpec = getenv("comspec")
set cursor on
run &cComSpec.
endif
if lCursOff
set cursor off
endif
set directory to &cDir
RETURN
*-- EoP: DosShell