Ini-File Processing. Perceptive Software Document Composition Studio
Reklama
Reklama
Ini-File Processing
About MLIniFile
The MonaLisa object MLIniFile enables you to perform read and write operations on .ini files. To load the
object, use the MonaLisa function GetObject .
Example
GetObject("IniFile","MLIniFile")
Functions of the Class MLInifile
Close
Closes an open .ini file.
Close
SYNTAX
EXAMPLE
Close()
GetObject("IniFile","MLIniFile")
...
IniFile.Close()
CopySection
Copies the specified section and identifiers in the specified .ini file. If either the identifier or the section do not exist, they will be created.
CopySection
SYNTAX CopySection(section, destFile)
ARGUMENTS section The name of the section.
EXAMPLE destFile Name of the '.ini' file in which the section copies in the following form.
[Drive\Path\]File name
GetObject("IniFile","MLIniFile")
IniFile.CopySection("Section_Test", "d:\test\MLTestIniFile_COPY.ini")
DeleteKey
Deletes the specified identifier from the respective section.
DeleteKey
SYNTAX
ARGUMENTS
RETURN
EXAMPLE
DeleteKey(section, key) section Name of the section. key Identifier you want to delete.
TRUE = Successful
FALSE = Unsuccessful
GetObject("IniFile","MLIniFile") ok = IniFile.DeleteKey("Delete-Section","Delete")
231
EraseSection
Deletes the specified section from an .ini file.
EraseSection
SYNTAX EraseSection(section)
ARGUMENTS section Name of the section to delete.
RETURN
EXAMPLE
TRUE = Successful
FALSE = Unsuccessful
GetObject("IniFile","MLIniFile") ok = IniFile.EraseSection("Delete-Section")
GetSectionNames
Returns a comma separated string containing all identifiers of a defined section.
GetSectionNames
SYNTAX GetSectionNames(section)
ARGUMENTS section Name of the section.
RETURN
EXAMPLE
Comma separated string of the identifiers.
GetObject("IniFile","MLIniFile") sectionNames = IniFile.GetSectionNames("Section_Test")
Open
Opens the specified .ini file for read or write operations.
Open
SYNTAX
ARGUMENTS
RETURN
EXAMPLE
Open(fileName) fileName Name of the .ini file in the form of
[Drive\Path\]File name
TRUE = Successful
FALSE = Not successful.
GetObject("IniFile","MLIniFile")
... ok = IniFile.Open("d:\test\MLTestIniFile.ini")
ReadBool
Reads the Boolean operator of the specified identifier from the respective section.
ReadBool
SYNTAX
ARGUMENTS
ReadBool(section, key) section Name of the section.
232
RETURN
EXAMPLE key Identifier
Value read.
GetObject("IniFile","MLIniFile")
...
Flag = IniFile.ReadBool("Section_Test","IsNewCustomer")
ReadInteger
Reads the integer value of the specified identifier from the respective section.
ReadInteger
SYNTAX ReadInteger(section, key)
ARGUMENTS section Name of the section. key Identifier
RETURN
EXAMPLE
Value read.
GetObject("IniFile","MLIniFile")
...
Year = IniFile.ReadInteger("Section_Test","Year")
ReadSectionToCommatext
Reads all identifier=value pairs from the specified section and returns them in a comma-separated string.
ReadSectionToCommatext
SYNTAX ReadSectionToCommatext(section)
ARGUMENTS section Name of the section.
RETURN
EXAMPLE
Comma separated string containing all identifier=value pairs in the following form.
"identifier=value1,identifier2=value2"
GetObject("IniFile","MLIniFile")
... section = IniFile.ReadSectionToCommatext("Section_Test")
ReadString
Reads the string of the specified identifier from the respective section.
ReadString
SYNTAX
ARGUMENTS
RETURN
EXAMPLE
ReadString(section, key) section Name of the section. key Identifier
Value read.
GetObject("IniFile","MLIniFile")
...
233
Name = IniFile.ReadString("Section_Test","Name")
WriteBool
Writes the Boolean value as the value of the specified identifier in the respective section.
If the section does not exist, it is created.
If the identifier does not exist, it is created.
WriteBool
SYNTAX
ARGUMENTS
EXAMPLE
WriteBool(section, key, value) section Name of the section key Identifier value The Boolean value to write
GetObject("IniFile","MLIniFile")
...
IniFile.WriteBool("Section_Test ","IsNewCustomer",TRUE)
WriteInteger
Writes the integer value as the value of the specified identifier in the respective section.
If the section does not exist, it is created.
If the identifier does not exist, it is created.
WriteInteger
SYNTAX WriteInteger(section, key, value)
ARGUMENTS section Name of the section
EXAMPLE key value
Identifier
Integer value to write
GetObject("IniFile","MLIniFile")
...
IniFile.WriteInteger("Section_Test ","Year",1998)
WriteSectionFromCommatext
Writes all identifier=value pairs to the specified section.
If either the identifier or the section do not exist, they are created.
WriteSectionFromCommatext
SYNTAX WriteSectionFromCommatext(section, commaText)
ARGUMENT
S section Name of the section commaText Comma-separated string in the form.
"identifier=value1,identifier2=value2"
234
EXAMPLE
GetObject("IniFile","MLIniFile")
...
IniFile.WriteSectionFromCommatext("Section_Test","NAME=MyName,Comp any=PA")
WriteString
Writes the string as a value of the specified identifier in the respective section.
If the section does not exist, it is created.
If the identifier does not exist, it is created.
WriteString
SYNTAX
ARGUMENTS
EXAMPLE
WriteString(section, key, value) section Name of the section key Identifier value Integer value to write
GetObject("IniFile","MLIniFile")
...
IniFile.WriteString("Section_Test ","Company","MyCompanyName")
235
Atsisiųsti
Reklama