ReadSectINI

Description: This subroutine read an entire section entry from a configuration file or a buffer containing one and returns a 2-dimensional array containing variable names and their values. Will not access .Startup or .Dynamic files.
Note: Access to configuration files is not reliable unless the caller holds the working copy lock. Acquiring the lock is a steady-state only operation, and therefore legacy operations that used script-mode access to these files are deprecated or no longer supported (see comments)
Returns: Array
Usage: Script Only.
Function Groups: File I/O
Related to: CheckFileExist | CheckPathExist | ReadINI | WriteINI | WriteSectINI |
Format: System.ReadSectINI(File, Section [[, UseBuff] , PtrSectionStatus )
Parameters:  
File
Required. Any text expression giving the absolute path and file name of the Settings file or the name of the buffer containing its contents.
Section
Required. Any text expression giving the name of the section in the file. This should not include the square brackets delimiting the section.
UseBuff
An optional parameter that is any logical expression. If true (non-0) the value of File must be a pointer to a buffer, if false (0) it is a file that is to be used. The default used if this parameter is omitted is false.
PtrSectionStatus
A flag used to inform the caller of what was found, according to the following table:

Value

Meaning

Invalid

when either of the first 2 parameters are invalid

0

when both section and settings exist

1

when no section is found

2

when section is found, but not settings

Comments:

For developers the lock means that access to VTScada working copy files, both reading and writing, should not be done without having the lock. The lock is across all applications and system layer VTScada code. The lock prevents two different piece of code from changing the same code such that one piece of code sees inconsistent data while the other code is in the middle of changing it.

This module is a member of the System Library, and must therefore be prefaced by \System. as shown in the "Format" section.

If your application predates version 11.2, use the backslash notation rather than dot: \System\

The array that is returned gives the variable names in its first row (Array[0][N]) and the variables' values in its second row (Array[1][N]). The return value will be invalid if the Settings file or section was not found, or if the section did not contain any variables. Searches performed by this function are case insensitive.

Example:

If 1 Main;
[
  Vars = System.ReadSectINI("C:\VTScada\Setup.ini" { Name of file },
                            "System" { Name of section },
                            0 { Read file format });
]

This creates the array Vars and stores in it all variables in the System section of the Settings.Dynamic file.