b = oDataTable.LoadFromFile(sFile, sParams)
|sFile||(String) Source file name (with the path) for loading the data. File must not have the "ini" or "csv" extension, the file type is determined by the filetype parameter. |
If a full path is not entered, it is completed relatively according to the application file folder. It is recommended to use the PROMOTIC path syntax - see PROMOTIC path to files and folders.
|sParams||(String) Text list of parameters that define the way of loading from the file. Entries with assigned value are separated by a semicolon, for example "filetype:ini;fmt:trans;rowname:boiler;".|
"filetype:xxx;" (mandatory) - It defines the type of the file specified by the sFile parameter
ini - type is a INI file.
csv - type is a CSV file. It is the multi-lined file of text values separated, for example, by a semi-colon. It is commonly used, for example, in the MsExcel program.
"fmt:xxx;" (optional) - It defines the format of stored data in the file. If it is not stated, the "fmt:standard;" value is presumed. The following formats are possible:
standard - The meaning depends on the file type:
csv - Values from rows of the CSV file are stored into corresponding rows in the table
ini - Sections of the INI file are the names of rows and keys of the INI file are the names of columns of the table. Example:
trans - Sections of the INI file are the names of columns of the table and keys of the INI file are the names of rows. Example:
"rowname:xxx;" (optional) - (only for INI) It defines the name of the row. If it is not stated, the value "rowname:r;" is presumed. The name of the row is created by this text amended by the row index, for example if it is the "rowname:rrr;", then the row names are "rrr0", "rrr1", etc.
"colnameheader:xxx;" (optional) - (only for CSV)
no (default) - in the first row of the file there are stored the data.
yes - in the first row of the file there aren't any data but names of columns.
"delimiter:xxx;" (optional) - (only for CSV) The separator of values in the CSV file. The allowed values are:
semicolon (default) - the delimiter is a semicolon.
comma - the delimiter is a comma.
space - the delimiter is a space.
tab - the delimiter is a tab.
number - i.e. the separator is defined as a decimal number of the ASCII character, for example "delimiter:124;" represents the "|" separator (vertical line).
"date.fmt:xxx;" (optional) - Date/time format. The allowed values are:
system (default) - the date/time format is set by OS Windows settings (e.g. 22.11.2010 16:30:15).
pm - PROMOTIC date/time format with 1 second accuracy (e.g. 2010.11.22 16:30:15).
pmmili - PROMOTIC date/time format with 1 millisecond accuracy (e.g. 2010.11.22 16:30:15.250).
real - data type of date/time format Date as a real number (e.g. 41392.123456789).
"real.dsep:xxx;" (optional) - (only for CSV) The format of decimal separator for real numbers. The allowed values are:
system (default) - the decimal separator is defined by OS Windows settings (e.g. 3,14).
dot - the decimal separator is (regardles on OS Windows settings) a period (e.g. 3.14).
comma - the decimal separator is (regardles on OS Windows settings) a comma (e.g. 3,14).
yes - When writing, the separator is added after the last value on the row, when reading, the empty value at the end of each row is ignored. From the CSV file standard point of view, this is not correct.
no (default) - The separators are present only between values on the same row, not at the end. From the CSV file standard point of view, this is correct.
The method loads data from the file and stores them in the existing rows in the table (from the beginning of the table). If there are more columns in the file than in the table, then the number of rows in the table increases to the required number. Then it is possible to load data for example into the table that has no row. But on loading the maximum number of rows that is set in the DataTable configuration page, mustn't be exceeded.
Loading from the file is performed per rows or per columns (according to the "fmt" parameter). If the end of the row/column is encountered, it is passed over to the next one. Thus not all values of the row/columns need be saved into the file.
"Read only" columns: Each cell is empty at the beginning. The cell is considered empty also if it contains numeric value 0 or an emty string "". New value can be written into such cell. After writing a non-zero value into the "Read only" column the cell is "locked". "Locked cell" becomes a constant and cannot be written again. Other still "unlocked" cells can be written into as needed. Methods that write into multiple cells simultaneously will write the values only into "unlocked cells" while the content of "locked" cells remains unchanged.
oDataTable.LoadFromFile "#app:CfgData.csv", "filetype:csv;colnameheader:no;delimiter:semicolon;real.dsep:dot;date.fmt:pm;"
oDataTable.LoadFromFile "#app:CfgData.ini", "filetype:ini;rowname:boiler;"