Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper 5.2 . Technical Reference - <b>_itemarrayput()</b> http://www.X-Hacker.org [<<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 itemArr,
                         USHORT uiElem,
                         ITEM itemAdd
                       )

 Arguments

     itemArr is the array into which you want to place a new Item.

     uiElem is the element number of the array itemArr 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.

     itemAdd is the new Item to place into itemArr at element uiElem.

 Returns

     _itemArrayPut() always returns itemArr.

 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()

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