Object Creation and Initialization


To perform file input/output with IXFile you must first create object, then unlock its functionality by setting valid license key, and finally initialize it to appropriate mode of operation depending on your needs. All IXFile activities must start with these three operations performed in given order as shown below:
1. CREATE OBJECT
2. LICENSE OBJECT
3. INITIALIZE OBJECT

Creating Object

Uninitialized object is created with Constructor that also enables Unicode system calls on NT/2000/XP platforms and sets ANSI codepage as a default codepage for ANSI/Unicode conversion; see Unicode Support for more information. When no longer needed, object should be destroyed (either automatically or manually) to release resources.

Licensing Object

License key is set with SetLicenseKey method. You can specify any valid license key either permanent or trial (time-limited). License key is checked in most of IXFile methods; if it is recognized as invalid or expired methods fail. See License Keys for more information on license keys.

Initializing Object

Object is initialized with Initialize method that sets mode of operation of the object and allocates data buffers. Correct initialization is crucial because it determines lifetime behaviour of the object which cannot be changed dynamically. Mode of operation specifies type of access to the object (read, write or both), enables automatic file locking (for reading, writing or both), automatic file closing and specifies byte order of file data (little- or big-endian). During initialization, file data buffer of specified size is also allocated. Method has default parameters (read and write access, automatic file closing, 16KB buffer) that allows simplified initialization for quick start. Initialization parameters can be later examined with GetMode and GetBufferSize methods.

Examples

C++

// error handling is omitted for clarity


  int main(int, char**)
  {
   IFile ixf1;    // object is created automatically
   IFile *ixf2;

// create dynamic object

   ixf2 = new IFile();

// set license keys

   ixf1.SetLicenseKey("YOURLICENSEKEY");
   ixf2->SetLicenseKey("YOURLICENCEKEY");

// default initialization 
// read/write access, auto file closing, 16KB buffer

   ixf1.Initialize(); 

// initialize for read-only access 
// with automatic locking and 1KB buffer

   ixf2->Initialize(IXF_MODE_READ | IXF_MODE_READLOCK, 1024); 

// open first file
// mode of operation forces read/write access to the file
// and exclusive access (file is not shared)

   ixf1.Open("test1.bin"); 

// open second file
// mode of operation forces read-only access to the file
// and read/write sharing (see help for Open() description)

   ixf2->Open("test2.bin"); 

    .
    .
    .

// second file must be closed manually because 
// object was initialized without
// auto closing feature

   ixf2->Close(); 

// destroy dynamic object

   delete ixf2; 

// first file is closed automatically
// on object destruction

   return(0);

  }

BASIC

' error handling is omitted for clarity


  Sub Main()

   Dim ixf1 As IXFile, ixf2 As IXFile

' create objects

   Set ixf1 = New IXFile
   Set ixf2 = New IXFile

' set license keys

   ixf1.SetLicenseKey "YOURLICENSEKEY"
   ixf2.SetLicenseKey "YOURLICENSEKEY"

' default initialization 
' read/write access, auto file closing, 16KB buffer

   ixf1.Initialize

' initialize for read-only access 
' with automatic locking and 1KB buffer

   ixf2.Initialize IXF_MODE_READ Or IXF_MODE_READLOCK, 1024

' open first file
' mode of operation forces read/write access to the file
' and exclusive access (file is not shared)

   ixf1.Open "test1.bin" 

' open second file
' mode of operation forces read-only access to the file
' and read/write sharing (see help for Open() description)

   ixf2.Open "test2.bin"

    .
    .
    .

' second file must be closed manually because 
' object was initialized without
' auto closing feature

   ixf2.Close 

' both objects are destroyed by the system
' first file is also closed automatically

  End Sub

See Also

Constructor, SetLicenseKey, Initialize, GetMode, GetBufferSize