home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
FOXPRO
/
TABLES
/
TBLSRC
/
TBLINIT.PRG
< prev
next >
Wrap
Text File
|
1992-11-13
|
3KB
|
106 lines
* Program :TblInit.prg
* Author :Mark D. Miller
* Date :12-Nov-1992
* Notice : Copyright (c) 12-Nov-1992 by Mark D. Miller
* All Rights Reserved.
* Notes :The table initialization routines for individual tables
*
* The includes
*
#include table.hdr
#include string.hdr
#include fileio.hdr
#include pick.hdr
#include colors.hdr
#include io.hdr
#include warn.hdr
*
* FORCE externs
*
VARDEF EXTERN
byte __color_std
ENDDEF
*
* Global Table Memory
*
VARDEF
CHAR( 12 ) OpenTableName
CHAR( 40 ) TblPath && This var only needs to be here
FILE OpenTableHandle
UINT TableCnt, TableCnt2, TableKy
LONG DataList, KeyList
INT TableType
INT TableIdx
ENDDEF
*...
* T H E R O U T I N E S *
*...
* Function :InitTable
* Date :11-Nov-1992
* Parameters:Name Name of the table file to initialize
* :
* Return Val:.T. Initialization successfull
* :.F. Initialization failed
* Notes :This routine opens and reads the specified table file into
* pick lists for field processing.
*
FUNCTION LOGICAL InitTable
PARAMETERS const CHAR( 8 ) name
VARDEF
CHAR( 255 ) TableIn
uint s
byte c_color_std
ENDDEF
*
* Create Pick list to show entries in.
*
TblPath = trim(TblPath)
OpenTableName = TRIM( name )+".tbl"
IF .NOT. F_OPEN( OpenTableHandle, TblPath+OpenTableName, &F_READ )
s = savescrn(24,0,24,79)
c_color_std = __color_std
__color_std = &RED_WHITE
@ 23, 1
WAIT CHR( 7 )+"InitTable: Fatal Error: can't find table!"+TblPath+OpenTableName
restorescrn(s)
__color_std = c_color_std
RETURN .F.
ENDIF
*
* Bypass first line which is comment line (get table type)
*
DataList = PICK_INIT()
F_GETLN( OpenTableHandle, TableIn )
TableType = i_VAL( TableIn )
IF TableType = 0 .OR. TableType > 2
TableType = 1 && Numerical table
ENDIF
IF TableType = 2 && Keyed table
KeyList = PICK_INIT()
ENDIF
*
* Load the table entries in the pick list
*
TableCnt = 0
DO WHILE .NOT. F_EOF( OpenTableHandle )
F_GETLN( OpenTableHandle, TableIn )
IF TableType = 2
PICK_ADD( KeyList, LEFT( TableIn, AT( "-", TableIn )-1 ) )
PICK_ADD( DataList, SUBSTR( TableIn, AT( "-", TableIn )+1, LEN( TableIn ) ) )
ELSE
PICK_ADD( DataList, TableIn )
ENDIF
TableCnt = TableCnt + 1
ENDDO
F_CLOSE( OpenTableHandle )
RETURN .T.
ENDPRO
* EOF : TblInit.prg