10 - 12 - 2024

DBF DataBase

Block DBFStorage

License: Hobby, Industrial

The block combines great possibilities for easy DBF database design, automatic creation of database indexes, fast read / write operations, self-maintenance of the database, old records are automatically erased, so the database is maintenance free.

DBF Database design:

The design of the DBF database can be set through the DataSet property. An interface opens in which the user can add the columns of the database and indicate what type they are - Analogue, Digital, Integer, DateTime, String. There is only one feature here, one of the columns entered for DateTime type should be declared a leading one, it means that an index will be created automatically on it - just check the CheckBox on the table of the property at column LeadingDate. The listed columns of the database will appear as block inputs. When adding a new database record, the values of the columns in the record will be taken from the current values of the inputs.

 

Parameters:

Common Parameters:

  • DataSet - for a DBF Database design;
  • Disable - if the parameter is checked, the block will not work on a running diagram;
  • FullDBFFileName - includes device, path, filename with DBF extension. If the path is not valid, the block will not start;
  • StoreType - may have one of the following values: LastRecords, LastSeconds, LastMinutes, LastHours, LastDays. Works in combination with the StoreLast parameter. For example, if StoreType is LastMinutes and StoreLast is 10, the block will delete all the records older than 10 mins automatically.
  • StoreLast - defines the number of stored records in the database;
  • StoreLastAtMemory - defines the number of stored records in the memory. Each new record is added simultaneously to the database and to the block memory. The OutDataSet output of the block contains only the records added to the block memory. The number of supported records in the database and in the memory may be different.

Parameter SaveSettings - the parameter is related to exported records - for some database applications, the records may need to be periodically exported and uploaded to a FTP server, for example. For this purpose, just click on parameter SaveSettings and edit the settings below:

  • Add ObjectID to exported file name - the value of ObjectID will be added to the exported file name;
  • ObjectID - if the database has a column with name ObjectID and with type Integer, all newly added records will have the value specified in this parameter. This is an important parameter if at a later stage the new records are exported and then imported into a common database, so we will distinguish the source of the data records;
  • ExportType - determines the type of exported file. May have one of the following values: DBF, Comma Separated (Text file);
  • SaveFolder - path of the exported file;
  • Save last type - may have one of the following values: AllRecords (exports all existing records), LastRecords (exports last records determined from parameter SaveLast), OnlyNewRecords (exports only newly added records);
  • Num last records - this parameters is used only when parameter Save last type is LastRecords;
  • ZIP exported file - exported file will be archived;
  • Add next NUM in ZIP file name - if the exported file is archived, the name of the file will contains a sequential number that will increase with one for each next export;

 

Block's inputs:

  • Append - when the input becomes to high value, a new record will be added to the database and to memory of the block. Then the output OnReady will become in high level for a short time and the otput OutDataSet will contains the new record too;
  • DeleteOld - deletes old records in the database and at the memory;
  • Reload - loads again all the records from the database to the memory - the output OutDataSet will be refreshed;
  • DoSave - exports the stored records in database to extenal file (DBF or Text);
  • SaveDriveLetter - the drive of the saved path can be changed runtime with this parameter. It has to contain only one character;

 

Block's outputs:

  • OutDataSet - contains all the records of database, related to parameters StoreType, StoreLastAtMemory;
  • OnReady - becomes at high level, when new record is added;
  • NumRecords - number of records currently in database;
  • OnSaved - the exported file is saved;
  • OnSaveError - becomes in high level in case of export error;

 

For example, please open DBF.nsm demo file.