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.3 . Technical Reference - <b>_itemarraynew()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _itemArrayNew()
 Create a new item as an array
------------------------------------------------------------------------------
 C Prototype

     #include "item.api"
     ITEM _itemArrayNew(
                         USHORT uiSize
                       )

 Arguments

     uiSize is the number of elements with which to initialize the array.
     _itemArrayNew() will accept a zero-element array.  This means that
     arrays created will have no elements ({}).

 Returns

     A new item of type array with a _itemSize() of uiSize.

 Description

     You can use the _itemArrayNew() function to create a new CA-Clipper-
     level array.  usSize will accept zero and will create a zero-length
     array.

     Note:  When creating a new item reference, remember to release the
     item reference with _itemRelease() after returning it to CA-Clipper or
     when it is no longer needed.

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

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