PxConfigOpen

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

# `PxConfigOpen`

`PxConfigOpen` -- Opens a configuration file.

## Syntax

    PxConfigOpen (cfgfile, mode)

## Arguments

`cfgfile`

  A configuration file.

`mode`

  One or more of these flags: PXCONFIG_READ| PXCONFIG_WRITE|PXCONFIG_CREATE.

## Returns

-1 on success, 0 on error.

## Description

This function opens the `cfgfile` according to the `mode` specified. If the PXCONFIG_CREATE flag is set for the `mode`, the PXCONFIG_WRITE flag must be set as well.

## Example

This example, `ex_PxConfigOpen.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

    o = PxConfigOpen("configtest.txt", PXCONFIG_READ);
    princ(o,"\n");

    princ(int_p('a'), "\n");

    princ("PxConfigReadInt    : ",PxConfigReadInt("Section One", "LineOne", 0),"\n");
    princ("PxConfigReadLong   : ",PxConfigReadLong("Section One", "LineTwo", 0),"\n");
    princ("PxConfigReadShort  : ",PxConfigReadShort("Section One", "LineThree",0),"\n");

    princ("PxConfigReadChar   : ",PxConfigReadChar("Section Two", "LineTwo", 'x'),"\n");
    princ("PxConfigReadString : ",PxConfigReadString("Section Two", "LineTwo", "nothing", 14),"\n");
    princ("PxConfigReadString : ",PxConfigReadString("Section Two", "LineThree", "nothing", 14),"\n");

    c = PxConfigClose();
    princ(c,"\n");

## See Also

In Photon documentation: PxConfigOpen.

Prev | Home | Next
`PxConfigNextString` | Up | `PxConfigRead`

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