home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
FOXPRO
/
TABLES
/
TBLSRC
/
TBLVERFY.PRG
< prev
Wrap
Text File
|
1992-11-13
|
6KB
|
174 lines
* Program :TblVerfy.prg
* Author :Mark D. Miller
* Date :12-Nov-1992
* Notice : Copyright (c) 12-Nov-1992 by Mark D. Miller
* All Rights Reserved.
* Notes :Verify the chosen value is in the current table.
*
* The includes
*
#INCLUDE TABLE.HDR
#INCLUDE IO.HDR
#INCLUDE KEYS.HDR
#INCLUDE STRING.HDR
#INCLUDE PICK.HDR
#include colors.hdr
#INCLUDE WARN.HDR
*
* Global Table Memory
*
VARDEF EXTERN
CHAR( 12 ) OpenTableName
FILE OpenTableHandle
UINT TableCnt, TableCnt2, TableKy
LONG DataList, KeyList
INT TableType
INT TableIdx
byte __color_std
ENDDEF
**********************************************************************
* T H E R O U T I N E S *
**********************************************************************
* Function :VerifyTable
* Date :11-Nov-1992
* Parameters:Name Name of the table
* :TableRow Row field is on
* :TableCol Column to begin printing
* :length Max length of print area
* :pkey Current field value
* :
* Return Val:.T. If entry found in table
* .F. If entry not found in table
* Notes :This is the heart of the table routines. This routine looks
* up the current field value in the table and/or reacts to the
* tab key and several cursor movement keys.
*
FUNCTION LOGICAL VerifyTable
PARAMETERS const CHAR( 8 ) name,;
const UINT TableRow,;
const UINT TableCol,;
const INT length,;
CHAR( 4 ) pkey
VARDEF
CHAR( 80 ) TableIn && 75 char data + 4 char key + '-'
LOGICAL fnd
CHAR( 4 ) pkey2, mykey
INT L
uint s
byte c_color_std
ENDDEF
*
* Init the table if not already
*
IF AT( Name, OpenTableName ) = 0
IF .NOT. InitTable( Name )
RETURN .T.
ENDIF
ENDIF
pkey2=TRIM( pkey )
IF TableKy <> &K_TAB
IF pkey2=""
@ TableRow, TableCol CLEAR TO TableRow, TableCol+length
IF TableKy = &K_ENTER .OR. TableKy = &K_ESC .OR. TableKy = &K_C_END .OR. ( TableKy > &K_HOME .AND. TableKy < &K_INS )
ClearTable()
ENDIF
RETURN .T. && Always allow to skip field
ENDIF
ENDIF
*
* Validate the choice against the list
*
IF TableType = 1
IF TableKy = &K_TAB
IF TableIdx+1 > TableCnt
TableIdx = 1
ELSE
TableIdx = TableIdx + 1
ENDIF
@ TableRow, TableCol CLEAR TO TableRow, TableCol+length
@ TableRow, TableCol ?? PICK_STR( DataList, TableIdx )
*
* Here we simply force the cursor to start of the field, and
* then delete any characters in the field before stuffing the
* new value into the field.
*
KEY_INT( &K_HOME )
KEY_INT( &K_DEL )
KEY_INT( &K_DEL )
KEY_INT( &K_DEL )
KEY_INT( &K_DEL )
pkey = I_STR( TableIdx )
KEYBOARD( pkey )
fnd = .T.
ELSE
IF I_VAL( pkey2 )=0
fnd=.F.
ELSE
IF I_VAL( pkey2 ) > TableCnt
fnd= .F.
ELSE
@ TableRow, TableCol CLEAR TO TableRow, TableCol+length
@ TableRow, TableCol ?? PICK_STR( DataList, I_VAL( pkey2 ) )
TableIdx = I_VAL( pkey2 )
fnd = .T.
ENDIF
ENDIF
ENDIF
ELSE
IF TableKy = &K_TAB
IF TableIdx+1 > TableCnt
TableIdx = 1
ELSE
TableIdx = TableIdx + 1
ENDIF
pkey = PICK_STR( KeyList, TableIdx )
@ TableRow, TableCol CLEAR TO TableRow, TableCol+length
@TableRow, TableCol ?? PICK_STR( DataList, TableIdx )
KEY_INT( &K_HOME )
KEY_INT( &K_DEL )
KEY_INT( &K_DEL )
KEY_INT( &K_DEL )
KEY_INT( &K_DEL )
KEYBOARD( pkey )
fnd = .T.
ELSE
TableCnt2 = 1
fnd = .F.
DO WHILE TableCnt2 < TableCnt+1 .AND. .NOT. fnd
mykey = PICK_STR( KeyList, TableCnt2 )
L = LEN( mykey )
IF LEFT( pkey2, L ) = mykey
fnd = .T.
@ TableRow, TableCol CLEAR TO TableRow, TableCol+length
@TableRow, TableCol ?? PICK_STR( DataList, TableCnt2 )
TableIdx = TableCnt2
ENDIF
TableCnt2 = TableCnt2 + 1
ENDDO
ENDIF
ENDIF
IF .NOT. fnd
s = savescrn(24,0,24,79)
c_color_std = __color_std
__color_std = &RED_WHITE
@ 23, 1
WAIT CHR( 7 )+"Table error!!! Press TAB for choices! -Press a key"
restorescrn(s)
__color_std = c_color_std
key_int(&K_HOME) && Reposition cursor
ELSE
IF TableKy = &K_ENTER .OR. TableKy = &K_ESC .OR. TableKy = &K_C_END .OR. ( TableKy > &K_HOME .AND. TableKy < &K_INS )
ClearTable()
ENDIF
ENDIF
RETURN fnd
ENDPRO
* EOF : TblVerfy.prg