Valid on UNIX and Windows
The WriteIniEntry function stores a value in an initialization (.ini) file. If the file does not exist, this function creates the file.
Function format:
WriteIniEntry(section as String, entry as String, value as String, grpfilename as String) as Boolean
WriteIniEntry(filename as String) as Boolean (Windows only)
Identifies the section in which to store the entry and value.
Specifies the entry in which to store the value.
Identifies the value to be stored.
Identifies the name of the initialization file.
The name of the addressed initialization file.
Note: In the case of WriteIniEntry{Filename as String} as Boolean, the cache of the system is flushed and therefore the new values become active without reboot.
On successful completion, the function returns TRUE; otherwise, returns FALSE.
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.
|
|