Managing information in initialization files
Functions for accessing
initialization files
PowerBuilder provides several functions you can use to manage
application settings in initialization files:
Function | Description |
---|---|
ProfileInt | Obtains the integer value of a setting in a profile file. |
ProfileString | Obtains the string value of a setting in a profile file. |
SetProfileString | Writes a value in a profile file. |
For complete information about these functions,
see the PowerScript Reference
.
For how to use the ProfileString functions
with the registry, see “Functions for accessing
initialization files”.
Support for multiple platforms
When you move an application initialization file from one
platform to another, you may need to convert line endings.
For more information about converting line
endings, see “Saving text files–what
line endings to use”.
The format of APP.INI
The examples below manage application information in a profile
file called APP.INI. This file keeps track of user preferences that
control the appearance of the application. It has a Preferences
section that stores four color settings:
1 |
[Preferences] |
1 |
WindowColor=Silver |
1 |
BorderColor=Red |
1 |
BackColor=Black |
1 |
TextColor=White |
Reading values
The following
script retrieves color settings from the APP.INI file:
1 |
wincolor = ProfileString & |
1 |
("app.ini", "Preferences", "WindowColor", "") |
1 |
brdcolor = ProfileString & |
1 |
("app.ini", "Preferences", "BorderColor", "") |
1 |
bckcolor = ProfileString & |
1 |
("app.ini", "Preferences", "BackColor", "") |
1 |
txtcolor = ProfileString & |
1 |
("app.ini", "Preferences", "TextColor", "") |
Setting values
The following
script stores color settings in the APP.INI file:
1 |
SetProfileString & |
1 |
("app.ini", "Preferences", "WindowColor", wincolor) |
1 |
SetProfileString & |
1 |
("app.ini", "Preferences", "BorderColor", brdcolor) |
1 |
SetProfileString & |
1 |
"app.ini", "Preferences", "BackColor", bckcolor) |
1 |
SetProfileString & |
1 |
("app.ini", "Preferences", "TextColor", txtcolor) |