Valid on UNIX and Windows
The ReadIniEntry function retrieves a value from a specified section in an initialization (.ini) file.
Function format:
ReadIniEntry(section as String, entry as String, result as String, filename as String) as Integer
Identifies the section containing the entry.
Identifies the entry whose associated string is to be retrieved.
Identifies the name of the initialization (.ini) file. If only the file name is specified in Windows environments, the Windows directory is searched, while in non-Windows environments, the current directory is searched.
Identifies the string variable that is to receive the value.
ReadIniEntry() and ReadIniSection() return an positive value if the call succeeds, otherwsise they return zero (0). This function searches the initialization file for an entry that matches the name specified by entry, under the section heading specified by section and then copies its associated string to the result variable.
Example:
Dim file, section, entry, value as string
Dim LF, CR as char
Dim rtr as integer
ClrScr()
LF = 0x0a
CR = 0x0d
file = "c:\dmscript.ini"
if Not(ExistFile(file)) then
rtr = CreateFile(file, O_TEXT)
if rtr = -1 then
SetStatus(1)
exit
end if
closeFile(rtr)
end if
section = "Section 1"
value = "Param_1 = Wert_1" + LF + "Param_2 = Wert_2"
if WriteIniSection( section, value, file) then
Print("WriteIniSection successfully completed.")
else
Print("WriteIniSection failed.")
endif
section = "Section 2"
entry = "Param_3"
value = "Wert_3"
if WriteIniEntry( section, entry, value, file) then
Print("WriteIniFile successfully completed.")
else
Print("WriteIniFile failed.")
endif
section = "Section 1"
rtr = ReadIniSection(section, value, file)
if (rtr > 0) then
Print( Str(rtr) + CR + LF + value)
else
Print("ReadIniSection failed.")
endif
section = "Section 2"
entry = "Param_3"
rtr = ReadIniEntry(section, entry, value, file)
if (rtr > 0) then
Print( Str(rtr) + CR + LF + entry + " = " + value)
else
Print("ReadIniEntry failed.")
endif
|
Copyright © 2014 CA Technologies.
All rights reserved.
|
|