ProfileInt PowerScript function
Description
Obtains the integer value of a setting in the profile file
for your application.
Syntax
|
1 |
<span>ProfileInt</span> ( <span>filename</span>, <span>section</span>, <span>key</span>, <span>default</span> ) |
|
Argument |
Description |
|---|---|
|
filename |
A string whose value is the name of the |
|
section |
A string whose value is the name of a |
|
key |
A string specifying the setting name |
|
default |
An integer value that ProfileInt will |
Return Values
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 Application Techniques.
Examples
These examples use a file called PROFILE.INI,
which contains the following:
|
1 |
[Pb] |
|
1 |
Maximized=1 |
|
1 |
[security] |
|
1 |
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 |
<span>ProfileInt</span>("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 |
IF <span>ProfileInt</span>("C:PROFILE.INI", "Security", & |
|
1 |
   "Class", 6) < 10 THEN |
|
1 |
   // Class is < 10 |
|
1 |
   MessageBox("Warning", "Access Denied") |
|
1 |
ELSE |
|
1 |
<span></span> ... // Some processing |
|
1 |
END IF |
See Also
-
ProfileInt method for
DataWindows in the DataWindow Reference or the online Help