Managing information in initialization files

Functions for accessing initialization files

PocketBuilder provides several functions you can use to manage application settings in initialization files.

Table 21-1: PocketBuilder initialization file functions

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 online Help.

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:

[Preferences]
WindowColor=Silver
BorderColor=Red
BackColor=Black
TextColor=White

Reading values

The following script retrieves color settings from the APP.INI file. Wincolor, brdcolor, bckcolor, and txtcolor are string variables:

wincolor = ProfileString("app.ini", "Preferences", "WindowColor", "")
brdcolor = ProfileString("app.ini", "Preferences", "BorderColor", "")
bckcolor = ProfileString("app.ini", "Preferences", "BackColor", "")
txtcolor = ProfileString("app.ini", "Preferences", "TextColor", "")

Setting values

The following script stores color settings in the APP.INI file:

SetProfileString("app.ini", "Preferences", "WindowColor", wincolor)
SetProfileString("app.ini", "Preferences", "BorderColor", brdcolor)
SetProfileString("app.ini", "Preferences", "BackColor", bckcolor)
SetProfileString("app.ini", "Preferences", "TextColor", txtcolor)