PxConfigForceEmptySection

PxConfigForceEmptySection — creates an empty section in a configuration file.

Syntax

PxConfigForceEmptySection (section)

		

Arguments

section

The name of the section, as a string.

Returns

-1 if the section was created or already exists, or 0 on failure.

Description

This function creates a new section in the configuration file. Although the PxConfigWrite functions create sections as necessary, sometimes it is necessary to force the creation of an empty section to convey application information. The newly created section becomes the internal current section.

Example

This example, ex_PxConfigForceEmptySection.g, and its configuration file (configtest.txt) are included in the product distribution. A copy of the configtext.txt configuration file is shown in the PxConfigRead reference page.

#!/usr/cogent/bin/phgamma

system("echo \n");
system("echo Copying config file to new file to run tests.");
system("cp configtest.txt configtest2.txt");
system("echo \n");
system("echo --------- Start example ----------");

op = PxConfigOpen("configtest2.txt", PXCONFIG_WRITE);
princ("\nOpened? (0 = no, -1 = yes): ", op,"\n");

princ("Section created? (0 = no, -1 = yes): ",PxConfigForceEmptySection("Section Five"),"\n");

cl = PxConfigClose();
princ("Closed? (0 = no, -1 = yes): ", cl,"\n");

system("echo \n");
system("echo --------- End example ----------");
system("echo \n");
system("echo Running diff to compare old and new config files:");
system("diff configtest.txt configtest2.txt");
system("echo \n");
system("echo Removing new config file.");
system("rm configtest2.txt");
system("echo \n");

See Also

In Photon documentation: PxConfigForceEmptySection.