Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Comix 3.0 Reference Manual - <b>cmxautoopen()</b> get/set automatic open mode http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
cmxAutoOpen()         Get/set automatic open mode
------------------------------------------------------------------------------

Synopsis

    cmxAutoOpen([lOn]) -> lPrev

Arguments

    lOn is an optional parameter.  If not provided, the current automatic
    open mode is unchanged.

    If lOn is .F., then the structural index is _not_ automatically
    opened when a database is USE'd.

    If lOn is .T. (the default), the structural index will be
    automatically opened when the database is USE'd.

Returns

    cmxAutoOpen() returns the previous setting of the automatic open mode.

Description

    cmxAutoOpen() is useful when you wish to have the advantages of a
    structural index, but want to avoid automatically opening the structural
    index.  Two specific examples of this are:

    o   Very safe recreation of indexes in a multi-user environment

    o   Appending from a database (where you used a different alias for
        the database when creating the .CDX tags)

Example

    cmxAutoOpen(.f.)            && Don't open structural index automatically
    use demo exclusive          && Try to open database for exclusive use
                                && (this way, we know no one else is using
                                && the file while we're recreating indexes)
    if (!netErr())
        ferase("demo.cdx")      && Delete .CDX.  Would be _disastrous_ if
                                && .CDX was open
        index on last tag last
        index on first tag first
    else
        ? "Can't reindex right now"
    endif

    cmxAutoOpen(.t.)            && Restore to default of opening .CDX
    use demo shared             && Bring database into use in shared mode

Example

    *   Append from a database with different alias example

    use demo alias foo
    index on foo->last tag last

    use demo2
    lOld := cmxAutoOpen(.f.)    && Turn off automatic structural index open
    append from demo            && Will implicitly do a USE DEMO, but
                                && DEMO.CDX won't be opened
    cmxAutoOpen(lOld)           && Restore previous setting

    *   APPEND FROM implicitly opens demo (as if a USE DEMO statement had
    *   been done)
    *
    *   If cmxAutoOpen() had not been called, DEMO.CDX would have been opened
    *   in the APPEND FROM statement and an "Alias Does Not Exist" error
    *   would have occurred (foo->last would not be valid, since the default
    *   alias is demo)

See Also

    cmxAutoOrder()


See Also: cmxAutoOrder()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson