ProfileString PowerScript function
Description
Obtains the string value of a setting in the profile file
for your application.
Syntax
1 |
<span>ProfileString</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 |
A string value that ProfileString will |
Return Values
String, with a maximum length of 4096
characters. Returns the string from key within section within filename.
If filename is not found, section is
not found in filename, or key is
not found in section, ProfileString returns default.
If an error occurs, it returns the empty string (“”). If any argument’s
value is null, ProfileString 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.
ProfileString 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 lines. Quotes around string values
in the INI file are optional:
1 |
[Employee]<br>Name=Smith<br> <br>[Dept]<br>Name=Marketing |
This statement returns the string contained in keyword
Name in section Employee in file C:PROFILE.INI and
returns None if there is an error. In the example, the return value
is Smith:
1 |
<span>ProfileString</span>("C:PROFILE.INI", "Employee", &<br>   "Name", "None") |
The following statements open w_marketing
if the string in the keyword Name in section Department of file C:PROFILE.INI is
Marketing:
1 |
IF <span>ProfileString</span>("C:PROFILE.INI", "Department", &<br>   "Name", "None") = "Marketing" THEN<br>   Open(w_marketing)<br>END IF |
See Also
-
ProfileString method
for DataWindows in the DataWindow Reference or the online Help