[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _itemArrayPut()
 Place an item into a CA-Clipper-level array element
------------------------------------------------------------------------------
 C Prototype

     #include "item.api"
     ITEM _itemArrayPut(
                         ITEM itmArr,
                         USHORT uiElem,
                         ITEM itmAdd
                       )

 Arguments

     itmArr is the array into which you want to place a new item.

     uiElem is the element number of the array itmArr for the new item.
     Remember that CA-Clipper arrays element numbers begin at one, not
     zero; like C arrays.  A zero value in this parameter will not be accepted.

     itmAdd is the new item to place into itmArr at element uiElem.

 Returns

     _itemArrayPut() always returns itmArr.

 Description

     The function _itemArrayPut() allows you to place values (as items) into
     CA-Clipper-level arrays.  Note that if the root array was passed to your
     Extend routine as a parameter, changes made through _itemArrayPut() will
     be reflected at the CA-Clipper level.  This is because all arrays in
     CA-Clipper are passed by reference rather than by value.

 Examples

     /*
     * MYACLONE()
     * ----------
     * myAClone( <aArray1> ) --> aNewArray
     */

     HIDE ITEM near _xAClone( ITEM aSrc );

     CLIPPER ARRAYCLONE( void )

     {
        ITEM aSource;            // Source array
        ITEM aCloned;            // New array

        /* Do parameters check */

        if ( PCOUNT != 1 )
        {
           return;
        }

        /* Get source array as ITEM */

        aSource = _itemParam( 1 );

        /* Clone source array  */

        aCloned = _xAClone( aSource );

        /* Return clone, release clone and source */

        _itemReturn ( aCloned );

        _itemRelease( aSource );
        _itemRelease( aCloned );

        return;
     }

     HIDE ITEM near _xAClone( ITEM aSrc )
     {
        ITEM   temp;
        ITEM   aTemp;
        ITEM   aNew;

        USHORT i;
        USHORT nLen;

        // If item not an array, return NIL
        if ( !( _itemType( aSrc ) == ARRAY ) )
           return ( _itemNew( NULL ) );

        // Get number of elements, create new array
        nLen = _itemSize( aSrc );
        aNew = _itemArrayNew( nLen );

        // For each element... get source & copy
        for ( i = 1; i <= nLen; i++ )
        {
           temp = _itemArrayGet( aSrc, i );

           // If it's an array, copy via recursion
           if ( _itemType( temp ) == ARRAY )
           {
              aTemp = _xAClone( temp );
              _itemArrayPut( aNew, i, aTemp );
              _itemRelease( aTemp );
           }
           else
           {
              _itemArrayPut( aNew, i, temp );
           }

           _itemRelease( temp );

        }

        return ( aNew );

     }

 Files  Library is CLIPPER.LIB, header file is Item.api.


See Also: _itemArrayGet() _itemArrayNew()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson