ProfileInt
PowerScript function
Description
Obtains the integer value of a setting in the profile file for your
application.
Syntax
|
1 |
ProfileInt ( filename, section, key, default ) |
|
Argument |
Description |
|---|---|
|
filename |
A string whose value is the name of the profile file. If |
|
section |
A string whose value is the name of a group of related |
|
key |
A string specifying the setting name in section whose |
|
default |
An integer value that ProfileInt will return if filename |
Return value
Integer. Returns default if filename is not found, section is not
found in filename, or key is not found in section, or the value of key is
not an integer. Returns -1 if an error occurs. If any argument’s value is
null, ProfileInt returns null.
Usage
Use ProfileInt or ProfileString to get configuration settings from a
profile file that you have designed for your application.
You can use SetProfileString to change values in the profile file to
customize your application’s configuration at runtime. Before you make
changes, you can use ProfileInt and ProfileString to obtain the original
settings so you can restore them when the user exits the
application.
ProfileInt, ProfileString, and SetProfileString can read or write to
files with ANSI or UTF16-LE encoding on Windows systems, and ANSI or
UTF16-BE encoding on UNIX systems.
Windows registry
ProfileInt can also be used to obtain configuration settings from
the Windows system registry. For information on how to use the system
registry, see the discussion of initialization files and the Windows
registry in the section called “Managing Initialization Files and the Windows Registry” in Application Techniques.
Examples
These examples use a file called PROFILE.INI, which contains the
following:
|
1 2 3 4 |
[Pb] Maximized=1 [security] Class=7 |
This statement returns the integer value for the keyword Maximized
in section PB of file PROFILE.INI. If there were no PB section or no
Maximized keyword in the PB section, it would return 3:
|
1 |
ProfileInt("C:PROFILE.INI", "PB", "maximized", 3) |
The following statements display a MessageBox if the integer value
for the Class setting in section Security of file C:PROFILE.INI is less
than 10. The default security setting is 6 if the profile file is not
found or does not contain a Class setting:
|
1 2 3 4 5 6 7 |
IF ProfileInt("C:PROFILE.INI", "Security", & "Class", 6) < 10 THEN // Class is < 10 MessageBox("Warning", "Access Denied") ELSE ... // Some processing END IF |
See also
ProfileInt method for DataWindows in the section called “ProfileInt” in DataWindow Reference.