home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d07xx
/
d0766.lha
/
ISAM
/
examples
/
test.c
< prev
Wrap
C/C++ Source or Header
|
1992-11-21
|
28KB
|
1,003 lines
; /* you can execute this file to compile it (if you're using lattice/SAS C )
lc test
blink from LIB:c.o test.o LIB LIB:lcm.lib LIB:lc.lib LIB:amiga.lib
quit
*/
#include <MYLIB:ISAMLibPROTO.h>
#include <stdio.h>
struct Library *ISAMBase = NULL;
/* remove proto parm-names if your compiler can't handle them. */
/* remove protos entirely, " " " " " " */
void FFlush ( void );
void FlushScan ( char *fmt, void *ptr );
void FillOut ( char *str, int strlen, int len );
void HandlePrefix ( int keyno, void **ppprefix, int *pplen );
void HandleKey ( int keyno, void **ppkey );
void HandleRange ( int keyno, int itertype, void **ppfrom, void **ppto );
int main ( int argc, char *(argv[]) );
struct Employee {
/* 00 */ char Class;
/* 01 */ char LastName [15];
/* 16 */ char FirstName[16];
/* 32 */ double Salary;
/* 40 */ ULONG EmpNo;
/* 44 */ char SSN [9];
}; /* 53 */
#define MAXKEYNO 3
char str80[81];
int len, i, select, keyno;
long ErrorCode;
ULONG RecNo, CountMax, Count;
char c, from [17], to [17], key [17], prefix [17];
char KeyReturn [17]; /* enough for largest key, plus 1 */
void *KeyRet = &KeyReturn[0];
void *pfrom, *pto, *pkey, *pprefix;
int itertype;
ULONG ISAMHandle, ulfrom, ulto, ulkey;
char SpecsFileName [] = "DATA:Employee.specs";
BOOL Lockk;
double dfrom, dto, dkey;
struct Employee Rec, tmpRec;
/*--------------------------------- FFlush -----------------------------------*/
void FFlush ()
/* if any string output is cut off because it's too long ( Ex: "%16s") */
/* we don't want the overflow to count for part of the next scanf. */
{
char c;
while ( (c=getchar ( )) != '\n' )
;
return;
}
/*------------------------------ FlushScan ----------------------------------*/
void FlushScan ( fmt, ptr )
/* this function preforms a scan, and flushes anything past the first */
/* whitespace, so we don't start assigning extra input to the next scanf. */
char *fmt;
void *ptr;
{
scanf ( fmt, ptr );
FFlush ();
}
/*-------------------------------- FillOut ----------------------------------*/
void FillOut ( str, strlen, len )
char *str;
int strlen, len;
{
int i;
if ( ( str == NULL ) || ( len == 0 ) )
return;
for ( i=strlen; i<len; i++ )
str[i] = ' ';
return;
}
/*------------------------------ HandlePrefix -------------------------------*/
void HandlePrefix ( keyno, ppprefix, plen )
int keyno, *plen;
void **ppprefix;
{
switch ( keyno )
{
case 0 :
printf ( "\nprefix :" );
FlushScan ( "%16s", &prefix );
len = strlen ( prefix );
*ppprefix = &prefix[0];
*plen = len;
printf ( "\n'%s'", prefix );
printf ( "\n" );
break;
case 3 :
printf ( "\nprefix :" );
FlushScan ( "%9s", &prefix );
len = strlen ( prefix );
*ppprefix = &prefix[0];
*plen = len;
printf ( "\n'%s'", prefix );
printf ( "\n" );
break;
default:
break;
}
return;
}
/*------------------------------ HandleKey -------------------------------*/
void HandleKey ( keyno, ppkey )
int keyno;
void **ppkey;
{
switch ( keyno )
{
case 0 :
printf ( "\nkey :" );
FlushScan ( "%16s", &key );
FillOut ( key, strlen ( key ), 16 );
*ppkey = &key[0];
printf ( "\n'%16.16s'", key );
printf ( "\n" );
break;
case 1 :
printf ( "\nkey :" );
FlushScan ( "%lf", &dkey );
*ppkey = &dkey;
printf ( "\n%8.2lf", dkey );
printf ( "\n" );
break;
case 2 :
printf ( "\nkey :" );
FlushScan ( "%lu", &ulkey );
*ppkey = &ulkey;
printf ( "\n%lu", ulkey );
printf ( "\n" );
break;
case 3 :
printf ( "\nkey :" );
FlushScan ( "%9s", &key );
FillOut ( key, strlen ( key ), 9 );
*ppkey = &key[0];
printf ( "\n'%9.9s'", key );
printf ( "\n" );
break;
default:
break;
}
return;
}
/*----------------------------- HandleRange ------------------------------*/
void HandleRange ( keyno, itertype, ppfrom, ppto )
int keyno, itertype;
void **ppfrom, **ppto;
{
*ppfrom = NULL;
*ppto = NULL;
switch ( keyno )
{
case 0 :
if ( (itertype == 1) || ((itertype >=4) && (itertype <=9)) )
{
printf ( "\nfrom :" );
FlushScan ( "%16s", &from );
FillOut ( from, strlen ( from ), 16 );
*ppfrom = &from[0];
printf ( "\n'%16.16s'", from );
printf ( "\n" );
}
if ( (itertype >=2) && (itertype <=7) )
{
printf ( "\nto :" );
FlushScan ( "%16s", &to );
FillOut ( to, strlen ( to ), 16 );
*ppto = &to[0];
printf ( "\n'%16.16s'", to );
printf ( "\n" );
}
break;
case 3 :
if ( (itertype == 1) || ((itertype >=4) && (itertype <=9)) )
{
printf ( "\nfrom :" );
FlushScan ( "%9s", &from );
FillOut ( from, strlen ( from ), 9 );
*ppfrom = &from[0];
printf ( "\n'%9.9s'", from );
printf ( "\n" );
}
if ( (itertype >=2) && (itertype <=7) )
{
printf ( "\nto :" );
FlushScan ( "%9s", &to );
FillOut ( to, strlen ( to ), 9 );
*ppto = &to[0];
printf ( "\n'%9.9s'", to );
printf ( "\n" );
}
break;
case 1 :
if ( (itertype == 1) || ((itertype >=4) && (itertype <=9)) )
{
printf ( "\nfrom :" );
FlushScan ( "%lf", &dfrom );
*ppfrom = &dfrom;
printf ( "\n%8.2lf", dfrom );
printf ( "\n" );
}
if ( (itertype >=2) && (itertype <=7) )
{
printf ( "\nto :" );
FlushScan ( "%lf", &dto );
*ppto = &dto;
printf ( "\n%8.2lf", dto );
printf ( "\n" );
}
break;
case 2 :
if ( (itertype == 1) || ((itertype >=4) && (itertype <=9)) )
{
printf ( "\nfrom :" );
FlushScan ( "%lu", &ulfrom );
*ppfrom = &ulfrom;
printf ( "\n%lu", ulfrom );
printf ( "\n" );
}
if ( (itertype >=2) && (itertype <=7) )
{
printf ( "\nto :" );
FlushScan ( "%lu", &ulto );
*ppto = &ulto;
printf ( "\n%lu", ulto );
printf ( "\n" );
}
break;
default:
break;
}
return;
}
/*
==================================== MAIN =================================
*/
main ( argc, argv )
int argc;
char *(argv[]);
{
if ( (ISAMBase = OpenLibrary ( "isam.library", 0 )) == NULL )
{
printf ( "\nCouldn't open ISAM library.\n\n" );
exit ( 5 );
}
for (;;)
{
printf ( "\n" );
printf ( "\n1 : OpenISAMFile 12 : ReadNextISAMKey" );
printf ( "\n2 : StoreISAMRecord 13 : DeleteISAMRecords" );
printf ( "\n3 : ModifyISAMRecord 14 : LockISAMFile" );
printf ( "\n4 : DeleteISAMRecord 15 : UnLockISAMFile" );
printf ( "\n5 : ReadISAMRecord 16 : LockISAMRecord" );
printf ( "\n6 : ReadUniqueISAMRecord 17 : UnLockISAMRecord" );
printf ( "\n7 : SetUpISAMIterationRange 18 : UnLockAllISAMRecords" );
printf ( "\n8 : SetUpISAMIterationKey 19 : CloseISAMFile" );
printf ( "\n9 : SetUpISAMIterationPrefix 20 : " );
printf ( "\n10 : CountISAMRecords 21 : " );
printf ( "\n11 : ReadNextISAMRecord 22 : " );
printf ( "\n\n0 : exit\n\nSELECT ?" );
FlushScan ( "%d", &select );
printf ( "\n" );
if ( select == 0 )
break;
switch ( select )
{
case 1 :
printf ( "\nLock ( 1: No, 2: Yes ) ?" );
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == 1 )
Lockk = FALSE;
else if ( i == 2 )
{
Lockk = TRUE;
printf ( "\nLockType ( W/R ) ?" );
FlushScan ( "%1s", &c );
c = toupper ( c );
if ( ( c != 'W' ) && ( c != 'R' ) )
break;
}
else break;
printf ( "\nEnter a number to OpenISAMFile: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = OpenISAMFile ( SpecsFileName, Lockk, c,
TRUE, &ISAMHandle )) != OK )
printf ( "\nError %ld.", ErrorCode );
break;
case 2 :
printf ( "\nEmployee Class ?" );
FlushScan ( "%1s", str80 );
Rec.Class = str80[0];
printf ( "\nLast Name ?" );
FlushScan ( "%15s", str80 );
FillOut ( str80, strlen ( str80 ), 15 );
strncpy ( Rec.LastName, str80, 15 );
printf ( "\nFirst Name ?" );
FlushScan ( "%16s", str80 );
FillOut ( str80, strlen ( str80 ), 16 );
strncpy ( Rec.FirstName, str80, 16 );
printf ( "\nSalary ?" );
FlushScan ( "%lf", &Rec.Salary );
printf ( "\nEmployee Number ?" );
FlushScan ( "%lu", &Rec.EmpNo );
printf ( "\nSocial Security # ?" );
FlushScan ( "%9s", str80 );
FillOut ( str80, strlen ( str80 ), 9 );
strncpy ( Rec.SSN, str80, 9 );
printf ( "\nLock ( 1: No, 2: Yes ) ?" );
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == 1 )
Lockk = FALSE;
else if ( i == 2 )
{
Lockk = TRUE;
printf ( "\nLockType ( W/R ) ?" );
FlushScan ( "%1s", &c );
c = toupper ( c );
if ( ( c != 'W' ) && ( c != 'R' ) )
break;
}
else break;
printf ( "\nEnter a number to StoreISAMRecord: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
ErrorCode = StoreISAMRecord ( ISAMHandle, &Rec, Lockk, c, &RecNo );
switch ( ErrorCode )
{
case ERROR_RECORD_EXISTS :
printf ( "\nAn Employee already exists with that EmpNo or SSN#.");
printf ( "\n(A Record exists with the same Unique key value.)" );
break;
case OK :
printf ( "\nRecord# %lu", RecNo );
break;
default :
printf ( "\nError %ld.", ErrorCode );
break;
}
break;
case 3 :
printf ( "\nRec# :" );
FlushScan ( "%lu", &RecNo );
printf ( "\n" );
ErrorCode = ReadISAMRecord ( ISAMHandle, RecNo, FALSE, ' ', &tmpRec );
switch ( ErrorCode )
{
case ERROR_DELETED_RECORD :
printf ( "\nThat record has been deleted." );
break;
case ERROR_RECORD_TOO_HIGH :
printf ( "\nThat record number is too high." );
break;
case OK :
break;
default:
printf ( "\nError %ld.", ErrorCode );
}
printf ( "\nEmployee Class ?\n" );
printf ( "%c\n", tmpRec.Class );
FlushScan ( "%1s", str80 );
Rec.Class = str80[0];
printf ( "\n" );
printf ( "\nLast Name ?\n" );
printf ( "%15.15s\n", tmpRec.LastName );
FlushScan ( "%15s", str80 );
FillOut ( str80, strlen ( str80 ), 15 );
strncpy ( Rec.LastName, str80, 15 );
printf ( "\n" );
printf ( "\nFirst Name ?\n" );
printf ( "%16.16s\n", tmpRec.FirstName );
FlushScan ( "%16s", str80 );
FillOut ( str80, strlen ( str80 ), 16 );
strncpy ( Rec.FirstName, str80, 16 );
printf ( "\n" );
printf ( "\nSalary ?\n" );
printf ( "%8.2lf\n", tmpRec.Salary );
FlushScan ( "%lf", &Rec.Salary );
printf ( "\n" );
printf ( "\nEmployee Number ?\n" );
printf ( "%9lu\n", tmpRec.EmpNo );
FlushScan ( "%lu", &Rec.EmpNo );
printf ( "\n" );
printf ( "\nSocial Security # ?" );
printf ( "%9.9s\n", tmpRec.SSN );
FlushScan ( "%9s", str80 );
FillOut ( str80, strlen ( str80 ), 9 );
strncpy ( Rec.SSN, str80, 9 );
printf ( "\nEnter a number to ModifyISAMRecord: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
ErrorCode = ModifyISAMRecord ( ISAMHandle, RecNo, &Rec );
switch ( ErrorCode )
{
case ERROR_RECORD_EXISTS :
printf ( "\nAn Employee already exists with that EmpNo or SSN#.");
printf ( "\n(A Record exists with the same Unique key value.)" );
break;
case OK :
printf ( "\nRecord Modified." );
break;
default :
printf ( "\nError %ld.", ErrorCode );
break;
}
break;
case 4 :
printf ( "\nRec# :" );
FlushScan ( "%lu", &RecNo );
printf ( "\n" );
printf ( "\nEnter a number to DeleteISAMRecord: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
ErrorCode = DeleteISAMRecord ( ISAMHandle, RecNo );
switch ( ErrorCode )
{
case ERROR_DELETED_RECORD :
printf ( "\nThat record has been deleted." );
break;
case ERROR_RECORD_TOO_HIGH :
printf ( "\nThat record number is too high." );
break;
case OK :
printf ( "\nRecord deleted." );
break;
default:
printf ( "\nError %ld.", ErrorCode );
}
break;
case 5 :
printf ( "\nRec# :" );
FlushScan ( "%lu", &RecNo );
printf ( "\n" );
printf ( "\nLock ( 1: No, 2: Yes ) ?" );
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == 1 )
Lockk = FALSE;
else if ( i == 2 )
{
Lockk = TRUE;
printf ( "\nLockType ( W/R ) ?" );
FlushScan ( "%1s", &c );
c = toupper ( c );
if ( ( c != 'W' ) && ( c != 'R' ) )
break;
}
else break;
printf ( "\nEnter a number to ReadISAMRecord: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
ErrorCode = ReadISAMRecord ( ISAMHandle, RecNo, Lockk, c, &Rec );
switch ( ErrorCode )
{
case ERROR_DELETED_RECORD :
printf ( "\nThat record has been deleted." );
break;
case ERROR_RECORD_TOO_HIGH :
printf ( "\nThat record number is too high." );
break;
case OK :
printf ( "\nClass : '%c'", Rec.Class );
printf ( "\nLast Name : '%15.15s'", Rec.LastName );
printf ( "\nFirst Name : '%16.16s'", Rec.FirstName );
printf ( "\nSalary : %8.2lf", Rec.Salary );
printf ( "\nEmployee # : %9u", Rec.EmpNo );
printf ( "\nSS # : '%9.9s'", Rec.SSN );
printf ( "\n" );
break;
default:
printf ( "\nError %ld.", ErrorCode );
}
break;
case 6 :
printf ( "\nkeyno (0-%d) :", MAXKEYNO );
FlushScan ( "%d", &keyno );
printf ( "\nkeyno= '%d' ", keyno );
printf ( "\n" );
if ( keyno > MAXKEYNO )
break;
if ( keyno < 2 )
{
printf ( "\nKey not unique." );
break;
}
switch ( keyno )
{
case 2 :
printf ( "\nkey :" );
FlushScan ( "%lu", &ulkey );
pkey = &ulkey;
printf ( "\n%lu", ulkey );
printf ( "\n" );
break;
case 3 :
printf ( "\nkey :" );
FlushScan ( "%9s", &key );
FillOut ( key, strlen ( key ), 9 );
pkey = &key[0];
printf ( "\n'%9.9s'", key );
printf ( "\n" );
break;
default:
break;
}
printf ( "\nLock ( 1: No, 2: Yes ) ?" );
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == 1 )
Lockk = FALSE;
else if ( i == 2 )
{
Lockk = TRUE;
printf ( "\nLockType ( W/R ) ?" );
FlushScan ( "%1s", str80 );
c = toupper ( str80[0] );
if ( ( c != 'W' ) && ( c != 'R' ) )
break;
}
else break;
printf ( "\nEnter a number to ReadUniqueISAMRecord: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
ErrorCode = ReadUniqueISAMRecord ( ISAMHandle, keyno, pkey,
Lockk, c, &RecNo, &Rec );
switch ( ErrorCode )
{
case ERROR_NO_SUCH_RECORD :
printf ( "\nNo such record." );
break;
case OK :
printf ( "\nClass : '%c'", Rec.Class );
printf ( "\nLast Name : '%15.15s'", Rec.LastName );
printf ( "\nFirst Name : '%16.16s'", Rec.FirstName );
printf ( "\nSalary : %8.2lf", Rec.Salary );
printf ( "\nEmployee # : %9u", Rec.EmpNo );
printf ( "\nSS # : '%9.9s'", Rec.SSN );
printf ( "\n" );
break;
default :
printf ( "\nError %ld.", ErrorCode );
break;
}
break;
case 7 :
printf ( "\nkeyno (0-%d) :", MAXKEYNO );
FlushScan ( "%d", &keyno );
printf ( "\nkeyno= '%d' ", keyno );
printf ( "\n" );
if ( keyno > MAXKEYNO )
break;
printf ( "\nitertype (0-9) :" );
FlushScan ( "%d", &itertype );
printf ( "\n" );
if ( itertype > 9 )
break;
HandleRange ( keyno, itertype, &pfrom, &pto );
printf ( "\nEnter a number to SetUpISAMIterationRange: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = SetUpISAMIterationRange ( ISAMHandle, (UWORD) keyno,
(UBYTE) itertype, pfrom, pto )) != OK )
printf ( "\nError %ld.", ErrorCode );
break;
case 8 :
printf ( "\nkeyno (0-%d) :", MAXKEYNO );
FlushScan ( "%d", &keyno );
printf ( "\n" );
if ( keyno > MAXKEYNO )
break;
HandleKey ( keyno, &pkey );
printf ( "\nEnter a number to SetUpISAMIterationKey: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = SetUpISAMIterationKey ( ISAMHandle, (UWORD) keyno,
pkey )) != OK )
printf ( "\nError %ld.", ErrorCode );
break;
case 9 :
printf ( "\nkeyno (0-%d) :", MAXKEYNO );
FlushScan ( "%d", &keyno );
printf ( "\n" );
if ( keyno > MAXKEYNO )
break;
if ( (keyno == 1 ) || ( keyno == 2 ) )
break;
HandlePrefix ( keyno, &pprefix, &len );
printf ( "\nEnter a number to SetUpISAMIterationPrefix: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = SetUpISAMIterationPrefix ( ISAMHandle, (UWORD) keyno,
pprefix, len )) != OK )
printf ( "\nError %ld.", ErrorCode );
break;
case 10 :
printf ( "\nkeyno (0-%d) :", MAXKEYNO );
FlushScan ( "%d", &keyno );
printf ( "\n" );
if ( keyno > MAXKEYNO )
break;
printf ( "\nStop Counting at how many records:" );
FlushScan ( "%lu", &CountMax );
printf ( "\n" );
printf ( "\nEnter a number to CountISAMRecords: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = CountISAMRecords ( ISAMHandle, (UWORD) keyno,
CountMax, &Count )) != OK )
printf ( "\nError %ld.", ErrorCode );
else
printf ( "\n%lu Records.", Count );
break;
case 11 :
printf ( "\nkeyno (0-%d) :", MAXKEYNO );
FlushScan ( "%d", &keyno );
printf ( "\n" );
if ( keyno > MAXKEYNO )
break;
printf ( "\nLock ( 1: No, 2: Yes ) ?" );
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == 1 )
Lockk = FALSE;
else if ( i == 2 )
{
Lockk = TRUE;
printf ( "\nLockType ( W/R ) ?" );
FlushScan ( "%1s", str80 );
c = toupper ( str80[0] );
if ( ( c != 'W' ) && ( c != 'R' ) )
break;
}
else break;
printf ( "\nEnter a number to ReadNextISAMRecord: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
printf (
"\n RecNo C ---Last Name--- ---First Name--- -Salary- Employee# SocSecNum" );
do
{
ErrorCode = ReadNextISAMRecord ( ISAMHandle, (UWORD) keyno,
Lockk, c, &RecNo, &Rec );
switch ( ErrorCode )
{
case OK :
printf ( "\n %5lu %c %15.15s %16.16s %8.2lf %9lu %9.9s",
RecNo, Rec.Class, Rec.LastName, Rec.FirstName,
Rec.Salary, Rec.EmpNo, Rec.SSN );
break;
case ERROR_NO_MORE_RECORDS :
break;
default :
printf ( "\nError %ld.", ErrorCode );
break;
}
}
while ( ErrorCode == OK );
break;
case 12 :
printf ( "\nkeyno (0-%d) :", MAXKEYNO );
FlushScan ( "%d", &keyno );
printf ( "\n" );
if ( keyno > MAXKEYNO )
break;
printf ( "\nEnter a number to ReadNextISAMKey: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
do
{
ErrorCode = ReadNextISAMKey ( ISAMHandle, (UWORD) keyno,
&RecNo, KeyRet );
switch ( ErrorCode )
{
case OK :
printf ( "\nRecord# %5lu : ", RecNo );
switch ( keyno )
{
case 0 : printf ( "'%16.16s'", (char *) KeyRet ); break;
case 1 : printf ( "%8.2lf", *((double *) KeyRet) );break;
case 2 : printf ( "%9lu", *((ULONG *) KeyRet) ); break;
case 3 : printf ( "'%9.9s'", (char *) KeyRet ); break;
default: break;
}
break;
case ERROR_NO_MORE_RECORDS :
printf ( "\n" );
break;
default :
printf ( "\nError %ld.", ErrorCode );
break;
}
}
while ( ErrorCode == OK );
break;
case 13 :
printf ( "\nkeyno (0-%d) :", MAXKEYNO );
FlushScan ( "%d", &keyno );
printf ( "\n" );
if ( keyno > MAXKEYNO )
break;
printf ( "\nEnter a number to DeleteISAMRecords: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = DeleteISAMRecords ( ISAMHandle, (UWORD) keyno,
&Count )) != OK )
printf ( "\nError %ld", ErrorCode );
else
printf ( "\n%lu Records Deleted.", Count );
break;
case 14 :
printf ( "\nLockType ( W/R ) ?" );
FlushScan ( "%1s", str80 );
c = toupper ( str80[0] );
if ( ( c != 'W' ) && ( c != 'R' ) )
break;
printf ( "\nEnter a number to LockISAMFile: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = LockISAMFile ( ISAMHandle, c )) != OK )
printf ( "\nError %ld.", ErrorCode );
break;
case 15 :
printf ( "\nEnter a number to UnLockISAMFile: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = UnLockISAMFile ( ISAMHandle )) != OK )
printf ( "\nError %ld.", ErrorCode );
break;
case 16 :
printf ( "\nRec# :" );
FlushScan ( "%lu", &RecNo );
printf ( "\n" );
printf ( "\nLockType ( W/R ) ?" );
FlushScan ( "%1s", str80 );
c = toupper ( str80[0] );
if ( ( c != 'W' ) && ( c != 'R' ) )
break;
printf ( "\nEnter a number to LockISAMRecord: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = LockISAMRecord ( ISAMHandle, RecNo, c )) != OK )
printf ( "\nError %ld.", ErrorCode );
break;
case 17 :
printf ( "\nRec# :" );
FlushScan ( "%lu", &RecNo );
printf ( "\n" );
printf ( "\nEnter a number to UnLockISAMRecord: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = UnLockISAMRecord ( ISAMHandle, RecNo )) != OK )
printf ( "\nError %ld.", ErrorCode );
break;
case 18 :
printf ( "\nEnter a number to UnLockAllISAMRecords: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = UnLockAllISAMRecords ( ISAMHandle )) != OK )
printf ( "\nError %ld.", ErrorCode );
break;
case 19 :
printf ( "\nEnter a number to CloseISAMFile: ");
FlushScan ( "%d", &i );
printf ( "\n" );
if ( i == -1 )
break;
if (( ErrorCode = CloseISAMFile ( ISAMHandle )) != OK )
printf ( "\nError %ld.", ErrorCode );
break;
default :
break;
}
} /* for */
CloseLibrary ( ISAMBase );
printf ( "\n\n" );
return;
}