UNIX および Windows で有効です。
ReadIniEntry 関数は、初期化(.ini)ファイル内の指定セクションから値を取得します。
この初期化(.ini)ファイル関数の形式は、以下のとおりです。
ReadIniEntry(section as String, entry as String, result as String, filename as String) as Integer
エントリを含むセクションを指定します。
関連する文字列を取得するエントリを指定します。
初期化(.ini)ファイルの名前を指定します。 Windows 環境でファイル名のみを指定した場合は、Windows ディレクトリが検索されますが、Windows 以外の環境では現在のディレクトリが検索されます。
値を検索する文字列変数を指定します。
ReadIniEntry() および ReadIniSection() は、呼び出しに成功した場合、正の値を返します。失敗した場合は、ゼロ(0)を返します。 この関数は entry で指定した名前と一致するエントリを、初期化ファイル内の section で指定したセクション見出しで検索し、関連する文字列を結果変数にコピーします。
例: ReadIniEntry 関数
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 © 2013 CA.
All rights reserved.
|
|