WritePropertiesFile

(System Library)

Description: Write a single Settings file according to the properties in an INIFile structure.

Replaces WriteINI and WriteSectINI
Returns: Boolean indicating success or failure.
Usage: Script Only.
Function Groups: Configuration Management, File I/O
Related to: ReadPropertiesFileGetINIProperty | SetINIProperty
Format: System.WritePropertiesFile(INIData, TargetDirectory[, IsBuffer, Flushing])
Parameters:  
INIData
Required. An INIFile data structure, containing the file name to write to and the application properties to be written. Created as follows...  IniData = System.INIFiles(); 
See the Comments section for a description of the INIFile data structure.
TargetDirectory
A text expression providing a directory name to be concatenated in front of the FileName provided by the INIData parameter. If left blank, a base path to the VTScada install directory will be appended to the what is in the FileName member of the INIFile structure.
IsBuffer
An optional logical expression. Set TRUE if the TargetDirectory parameter is a buffer, which will receive the output of the function. Defaults to FALSE (0).
Flushing
Optional Boolean. Set TRUE to force flushing of data to storage immediately after the write This reduces the chance of data loss if the writing operation is interrupted. Defaults to FALSE.
Comments: Many properties can be modified with a single call to WritePropertiesFile.

The INIFile structure is as follows:

INIFiles Struct [
  FileName    { File name to the settings file. Path may be included,
                 but is better specified in the TargetDirectory
                 parameter.                                         };
  OEM         { TRUE if an OEM layer file                             };
  Workstation { Name of the workstation or invalid if global          };
  Layer       { Instance of application layer owning the file         };
  Dynamic     { TRUE if a dynamic property                            };
  Sections    { Dictionary of sections each element of which 
                is an array of Property structures         };
  Changed     { User sets to true if the file has been changed,
                initialized to false                                  };
 ]    

The INIProperty structure is…

INIProperty Struct [
    Name        { Variable name in the .startup/.dynamic file  };
    Value       { Simple value                                 };
    Comment     { Text comment if present in the file          };
    Hidden      { TRUE if not visible in Edit Properties GUI   };
  ];   

Note that if your intention is to write to a configuration file, this function should be called from within a ReadConfiguration callback or a ModifyConfiguration callback.

Example:

A System.INIProperty() structure is used in the INIFIles\Sections

    { Setup the INIFiles Struct }
    INIData = System.INIFiles();
    INIData\FileName    = Concat(ProfileName, ".ini");
    INIData\Workstation = Invalid;
    INIData\Dynamic     = 0;
    INIData\Sections    = Dictionary();
    INIData\Changed     = 0; 
    { Now write to the .ini file }
    System.WritePropertiesFile(INIData, "MyProject\Profiles\");