PxConfigDelete

Gamma/Photon: Using Gamma™ with the Photon microGUIŽ, Version 4.0
Prev |  | Next

# `PxConfigDelete`

`PxConfigDeleteEntry`, `PxConfigDeleteSection` -- delete entries and sections.

## Syntax

    PxConfigDeleteEntry (section, entry)
    PxConfigDeleteSection (section)

## Arguments

`section`

  The name of the section, as a string.

`entry`

  The name of the entry, as a string.

## Returns

-1 if the `entry` or `section` was deleted or doesn't exist, or 0 on failure.

## Description

These functions delete configuration entries or whole sections. The configuration file must first be opened with a call to `PxConfigOpen` with the `mode` set to PXCONFIG_WRITE. `PxConfigDeleteSection` deletes all entries of the `section` up to the beginning of the next section or the end of the file, and clears the internal current section.

## Example

This example, `ex_PxConfigDelete.g`, and its configuration file (`configtest.txt`) are included in the `gamma_ph_`#`_examples_1_QNX4.tgz` file available on the Cogent Web Site. 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 deleted? (0 = no, -1 = yes): ", PxConfigDeleteSection("Section Three"),"\n");
    princ("Entry deleted? (0 = no, -1 = yes): ", PxConfigDeleteEntry("Section Four", "LineTwo"),"\n");

    a = PxConfigNextString(20);
    for (a; a != nil; a = PxConfigNextString(20))
      princ("Next string: ", a,"\n");

    a = princ("Next section? ",PxConfigNextSection(),"\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: PxConfigDeleteEntry, PxConfigDeleteSection.

Prev | Home | Next
`PxConfigClose` | Up | `PxConfigForceEmptySection`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.