8.5.1 IniRead (read a value from an initialization file)
- Purpose
-
Reads a value from an initialization file (.INI file).
- Syntax
IniRead (FilePath, SectionName, ValueBuff, EntryName)
- Arguments
-
- FilePath
-
Write the full path of the initialization file as a character string or as a variable that stores this value.
- SectionName
-
Write a section name as a character string or as a variable that stores this value.
- ValueBuff
-
Specify a variable for storing the read data.
- EntryName
-
Write an entry name as a string, number, or as a variable that stores this value.
- Description
-
The IniRead command reads the value set in an entry of a specific section of the specified initialization file (.INI file) and stores the value in a specified variable. The command returns True on successful execution, or False if an error occurs.
If the initialization file specified in FilePath or the specific section of the initialization file specified in SectionName does not exist, a zero-length string ("") is stored in the variable specified in ValueBuff. Then the command returns True as the execution result.
- Note
-
Take care when specifying an initialization file in the folder set in the environment variable ProgramFiles (normally the Program Files folder on the system drive) or WinDir (normally the Windows folder on the system drive). For details, see 1.8.3 Effect of the executing user on command behavior.
- Important
-
If the value in an entry contains more than 1,024 bytes, only the first 1,024 bytes are stored in a variable. Do not attempt to read an entry containing more than 1,024 bytes.
- Example
-
The script below reads the following data from the initialization file ABC.INI in the startup folder.
; ABC.INI [Files] File01=Readme.txt File02=Abc.exe ' Script file ' Line 1 stores "Readme.txt" in variable file1. ' Line 2 stores "Abc.exe" in variable file2. Dim file1, file2 IniRead (_BIN_+"ABC.INI", "Files", file1, "File01") IniRead (_BIN_+"ABC.INI", "Files", file2, "File02")
- JP1/Script version
-
Supported from JP1/Script 01-00.