/* d4exampl.cpp (c)Copyright Sequiter Software Inc., 1990-1993.  
   All rights reserved. */

#include "d4all.hpp"

#ifdef __TURBOC__
extern unsigned _stklen = 10000 ;
#endif

void verify_switches(void) ;

FIELD4INFO fieldInfo[] =
{
{ "TEST_FIELD",'C',20,0 },
{ 0,0,0,0 },
};

void main()
{
  verify_switches( ) ;
  cout << "Switches Verified Successfully!" << endl ;

  Code4 cb ;
  cb.openError = 0 ;

#ifdef N4OTHER
  cb.autoOpen = 0 ;
#endif

  Data4 data ;

  if( data.open( cb, "TEST.DBF" ) == 0 )
    cout << endl << "TEST.DBF Opened" << endl ;
  else
  {
    if(data.create( cb,"TEST.DBF",fieldInfo) == 0)
      cout << endl << "TEST.DBF Created" << endl ;
  }
  cb.closeAll() ;
  cb.initUndo() ;
}


void verify_switches()
{
  long d4switch ;

  d4switch = u4switch() ;

  printf( "\n\nLibrary Conditional Compilation Switches:\n" ) ;
  if( d4switch & 1 )
    printf( "S4FOX - FoxPro Index File Compatibility\n" ) ;
  if( d4switch & 2 )
    printf( "S4CLIPPER - Clipper Index File Compatibility\n" ) ;
  if( d4switch & 4 )
    printf( "S4MDX - dBASE IV Index File Compatibility\n" ) ;
  if( d4switch & 8 )
    printf( "S4NDX - dBASE III or III PLUS Index File Compatibility\n" ) ;
  if( d4switch & 0x10 )
    printf( "S4DLL - Microsoft Windows DLL (S4DLL_BUILD on Library Build)\n" ) ;
  if( d4switch & 0x20 )
    printf( "S4WINDOWS - Microsoft Windows Static with Static Library\n" ) ;
  if( d4switch & 0x40 )
    printf( "S4OS2 - OS/2\n" ) ;
  if( d4switch & 0x40 )
    printf( "S4CODE_SCREENS - CodeScreens output Functions\n" ) ;
  if( d4switch & 0x100 ) 
    printf( "S4DEBUG - Extensive CodeBase Error Checking\n" ) ;
  if( d4switch & 0x200 )
    printf( "S4ERROR_HOOK - Custom Error Function\n" ) ;
  if( d4switch & 0x400 )
    printf( "\nS4LOCK_CHECK - Internal CodeBase Locking Diagnostics\n" ) ;
  if( d4switch & 0x800 )
    printf( "\nS4LOCK_HOOK - Custom Lock Failure Function\n" ) ;
  if( d4switch & 0x1000 )
    printf( "\nS4MAX - Maximum Memory Allocation Testing\n" ) ;
  if( d4switch & 0x2000 )
    printf( "\nS4MEMO_OFF - Memo File support source code removed\n" ) ;
  if( d4switch & 0x4000 )
    printf( "\nS4OLD_CODE - Support Functions from CodeBase 5.0\n" ) ;
  if( d4switch & 0x8000 )
    printf( "\nS4OPTIMIZE_OFF - Memory Optimization source code removed\n" ) ;
  if( d4switch & 0x10000L )
    printf( "\nS4PORTABLE - Maximum Portability\n" ) ;
  if( d4switch & 0x20000L )
    printf( "\nS4SAFE  - Immediate File Length Updates\n" ) ;
  if( d4switch & 0x40000L )
    printf( "\nS4SINGLE  - Multi-user support source code removed\n" ) ;

#ifdef S4OPTIMIZE_OFF
  if( (d4switch & 0x8000)  ==  0 )
    e4severe( e4result, "S4OPTIMIZE_OFF must be used in Library Build too.\n" ) ;
#else
  if( d4switch & 0x8000  )
    e4severe( e4result, "S4OPTIMIZE_OFF must be off in Library Build too.\n" ) ;
#endif

#ifdef S4FOX
  if( (d4switch & 1)  == 0 )
    e4severe( e4result, "S4FOX must be used in Library Build too.\n" ) ;
#endif

#ifdef S4CLIPPER
  if( (d4switch & 2)  == 0 )
    e4severe( e4result, "S4CLIPPER must be used in Library Build too.\n" ) ;
#endif

#ifdef S4MDX
  if( (d4switch & 4)  == 0 )
    e4severe( e4result, "S4MDX must be used in Library Build too.\n" ) ;
#endif

#ifdef S4NDX
  if( (d4switch & 8)  == 0 )
    e4severe( e4result, "S4NDX must be used in Library Build too.\n" ) ;
#endif
}
