ProfileString
PowerScript function
Description
Obtains the string value of a setting in the profile file for your
application.
Syntax
1 |
ProfileString ( filename, section, key, default ) |
Argument |
Description |
---|---|
filename |
A string whose value is the name of the profile file. |
section |
A string whose value is the name of a group of |
key |
A string specifying the setting name in section whose |
default |
A string value that ProfileString will return if |
Return value
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.
Windows registry
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 Managing 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 2 3 4 5 |
[Employee] Name=Smith [Dept] 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 2 |
ProfileString("C:PROFILE.INI", "Employee", & "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 2 3 4 |
IF ProfileString("C:PROFILE.INI", "Department", & "Name", "None") = "Marketing" THEN Open(w_marketing) END IF |
See also
ProfileString method for DataWindows in the section called “ProfileString” in DataWindow Reference.