Creating a Data File

Navigation:  How to Work with Data Files >

Creating a Data File

Previous pageReturn to chapter overviewNext page

 

Overview

 

Data files are an important component of a program and must have a well thought out structure.

We recommend the following:

 

Consider the objective of the data file when defining its type (to capture data, to display data or to have its data printed).

When selecting a data file’s encoding, consider the characters you intend to use in the data file – a wrong charset choice may affect the display of certain special characters.

 

If you require a more complex data structure and, subsequently, more complex queries, we recommend the use of the local database feature instead of the data file.

 

 

 

To Create a Data File

 

Step-by-step

 

There are two ways to create a data file:

 

Directly in the "Data Files" module.

Right-click an empty area within that module and click "Add File" in the resulting menu.

 

 

OR

 

Click wherever available (usually in the properties windows of data file related processes).

 

Whatever the path used, it opens a properties window and this is where the creation/setting up of a data file takes place.

 

Step-by-step

 

By default, the data file's properties window opens with the "General" tab.

 

 

1. Start by attributing an alias (internal MCL-Designer reference name) to the data file in the “File Alias” box.

 

Do NOT use special characters when defining an alias.

 

 

The maximum length for a data file alias is 30 characters.

 

 

2. Enter the data file's name in the “Physical File Name” option.

 

Do NOT use special characters. A file name should only contain alphabetic characters, numbers and the underscore “_” character (the underscore character is commonly, used to indicate a space). For more detailed information, register/log in to our MCL Community and access MCL's Knowledge Base ("File Name Best Practices").

 

The maximum length for the "Physical File Name" is 40 characters.

 

 

3. Select the file type in the “Type” option from the drop-down ("Capture"; "Lookup" or "Print"). See Data File Types.

 

4. Define the sorting field(s) in the “Sort on” box from the drop-down ("None"; "Field 1"; "Fields 1 + 2"; "Fields 1 + 2 + 3" and "Fields 1 + 2 + 3 + 4").

If you select an option with sorting fields, the "File Data Viewer" window will display the option.

 

5. Select a field separator character (such as (I) Pipe, (") Quotes, (,) Comma, etc.) in the “Field Separator” option.

 

6. Select the character that separates records in “Record Separator” from the drop-down ("CR+LF"; "CR" or "LF").

 

None

No defined record separator.

 

Choosing not to have a record separator means you MUST set a length for the records in the "Field Size & Filler"section - you must check "Fixed Length" and define the number of characters (step 13).

CR + LF

Moves the cursor to the beginning of the next line.

CR

(Carriage Return) Moves the cursor to the beginning of the same line.

LF

(Line Feed) Moves the cursor to the next line, to the the same position.

 

7. At this point, define the data file's "Advanced Settings".

Define the location, within the device, of the data file ("Default"; "Temp (Non Persistent)"; "Shared"; "External Storage" or "External Shared") in the "Location" box:

 

Default

Default storage disc space for files. The stored files will ONLY be accessible to the MCL application (and any background procedures).

Temp (Non Persistent)

Files are lost every time the RAM is cleaned up.

Shared

Internal storage disc space for files to be shared with 3rd party applications.

External Storage

External storage disc space for files accessible only to the application.

External Shared

External storage disc space for files shared across applications.

 

 

When selecting the location for the data file consider the following:

 

The target device.

For instance, if the device does not have a RAM partition (or an equivalent partition such as "cache disk"), “temp (non persistent)” is NOT an option (the device will end up storing the data files into the default folder for data files (<DATA> alias).

 

The Data File's objective.

If the file's content is to be managed solely by the MCL application (and its background procedures), we recommend the “Default” location. But, if you intend the data to be shared with 3rd party applications, select the “Shared” location for your data files.

 

 

8. Decide the data file format in the “Encoding” option ("Ansi (Default)", "UTF-8 Without BOM" or "UTF-16 Without BOM").

 

A data file with a "UTF-8 Without BOM" format does not support the customization of its fields in terms of length and fillers. If this is required, consider a different file format.

 

 

When selecting the charset/encoding, consider the characters used in the data file or database in question – some special characters may NOT be displayed if the wrong charset/encoding is defined.Ex: The Hindu character “अ” (included in a data file in use) can only be viewed with a “UTF 8 Without BOM” or “UTF-16 Without BOM” encoding.

 

 

The recommended codification for Android developed projects is "UTF-8 Without BOM" (or "UTF-16 Without BOM" if you require the data file's field to have a fixed length and fillers).

 

 

 

9. Define the file mode in the “Mode” drop-down  ("<Default>"; "<Optimized>"; "<Auto Commit>" or "<Shared>"):

 

Default

No explicit file close (for Windows CE devices).

Optimized

No file close is performed. An explicit file close needs to happen whenever necessary.

Auto Commit

File is automatically closed after write.

Shared

File is always closed after access.

 

10. Go to the "Design" tab to create the necessary fields of your data file.

 

 

11. The table presents default information ("Field_1" with its settings) and you can perform several operations:

 

a. To add more fields, click (located on an editing bar to the right of the tab)and continue to step 12.

 

b. To modify the default "Field_1" settings, click (located on an editing bar to the right of the tab) OR  double-click the field you want to modify and continue to step 12.

 

c. If you want to maintain the suggested settings, click to conclude the data file addition.

 

 

Use the editing bar to the right of the "Design" tab to add (); edit (); delete () and move ()the data file fields.

 

OR

 

Right-click the field you want to modify and select the appropriate option.

 

Delete Field...

Deletes the selected field.

Edit Field...

Opens the selected field's “Edit a Field of a Data File” window.

Copy Field...

Copies the selected field. Conclude by clicking "Paste Field...".

Paste Field...

Must be preceded by a "copy field". Pastes the copied field.

Duplicate Field...

Duplicates the selected field.

 

 

Performing options a. and/or b. opens a window where you can enter/edit data file fields.

 

 

12. Enter a new field name in the “Field Name” box.

 

13. Define the field's size by checking one of the available options:

 

"Variable Length"

Checking this option means that the size of the field can variate.

"Fixed Length"

If you check this option,you must, then, specify the number of characters allowed in the field and customize the field format by selecting a filler option from the drop-down. To remove these "filler" elements during a read operation, check the "Remove Filler on read".

 

If you did not define a record separator for your data file, you MUST select "Fixed Length" and fill in/define the related options.

 

 

If your data file has a "UTF-8 Without BOM" file format (defined in the "Encoding" option - "General" tab of the data file's properties window), you MUST check "Variable Length". The "Fixed Length" option does NOT apply to data files with a "UTF-8 Without BOM" format.

 

 

14. Define the "Field Type" by either checking the “String” (alphanumerical) option or “Numerical”. Checking this last option implies defining the number of decimals as well as the decimal separator character (“comma (,)” or “dot (.)”).

 

15. As a further option, define a “Default Value” for the field and add some comments that describe that field in the “Comment” box.

 

16. Click to apply your choices and return to the "Design" tab

 

17. Add as many fields as necessary.

 

a. Click .

 

b. Fill in the available options (steps 12 to 15) in the resulting window.

 

c. To apply your choices for each field and return to the "Design" tab, click .

 

18. When all the required fields have been created, click to conclude the operation.

 

 

To assist in the creation/edition of a data file field, you can also use the right-click menu in the "Design" tab and select the appropriate option.