WriteINI
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)
(System Library)
Description: | This subroutine writes a variable's value to a configuration file or a buffer containing one and returns its error code. Will not access .Startup or .Dynamic files. |
Returns: | Numeric |
Usage: | Script Only. |
Function Groups: | File I/O |
Related to: | CheckFileExist | CheckPathExist | ReadINI | ReadSectINI | WriteSectINI |
Format: | System.WriteINI(File, Section, VarName, Value [, UseBuff]) |
Parameters: |
File |
Required. Any text expression giving the absolute path and file name of the Settings file or a pointer to the buffer containing its contents, depending on parameter UseBuff. |
Section |
Required. Any text expression giving the name of the section in the file. This should not include the square brackets delimiting the section. |
VarName |
Required. Any text expression giving the name of the variable for which the value is to be set. |
Value |
Required. Any giving the value to be assigned to variable VarName. |
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. |
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 subroutine returns true (1) if the write was successful and invalid otherwise. If the Settings file, the section, or the variable does not exist, they will be created. |
Example:
If 1 Main; [ System.WriteINI("C:\VTScada\Setup.ini"){filename}, "System " { Name of section }, "OrderlyShutdown" { Name of variable }, 10 { Value of variable }, 0 { Write file format }); ]
This assigns a value of 10 to the variable OrderlyShutdown in the System section of the Setup.INI file.