[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _itemReturn()
 Return an item to CA-Clipper
------------------------------------------------------------------------------
 C Prototype

     #include "item.api"
     ITEM _itemReturn(
                       ITEM itmRet
                     )

 Arguments

     itmRet is the item you wish to return to CA-Clipper.

 Returns

     The same ITEM that was posted as the return value.

 Description

     The _itemReturn() function is used to send an item back to CA-Clipper in
     the form of a return value.

     Note:  Once an item is returned to CA-Clipper via _itemReturn(), it
     is considered as "referenced" by the CA-Clipper runtime system, and
     therefore, is not a candidate for garbage collection.  However, your C
     function must still call _itemRelease() after posting an item for return
     so that once the CA-Clipper variable which received the return value goes
     out of scope, it does get properly collected.

 Examples

     /*
     *
     * CharCount( cString, cChar )
     *
     * Count occurrences of a single character
     * in a CA-Clipper string.
     *
     */

     CLIPPER CharCount( void )
     {
        USHORT uiChars = 0;
        USHORT uiLen;
        USHORT i;
        HANDLE vmhString;

        BYTEP  cStringP;
        BYTE   cFindMe;

        ITEM   itmString, itmFindMe, itmRet;

        if (PCOUNT != 2)
        {
           _ret();               // NOTE: Withhold service
           return;               // Early return!
        }

        itmRet    = _itemPutNL( NULL, 0 );
        itmString = _itemParam( 1 );
        itmFindMe = _itemParam( 2 );

        if ( (_itemType( itmString ) == CHARACTER) &&
              (_itemType( itmFindMe ) == CHARACTER) )
        {
           _itemCopyC( itmFindMe, &cFindMe, 1 );

           vmhString = _xvalloc( _itemSize( itmString ), NULL );
           cStringP = _xvlock( vmhString );

           uiLen = _itemCopyC( itmString, cStringP, NULL );

           for( i = 0; i < uiLen; i++ )
           {
              if ( cStringP[i] == cFindMe )
                 uiChars++;
           }

           _xvunlock( vmhString );
           _xvfree( vmhString );

           itmRet = _itemPutNL( itmRet, (long)uiChars );

        }

        _itemReturn( itmRet );

        _itemRelease( itmRet );
        _itemRelease( itmString );
        _itemRelease( itmFindMe );

        return;
     }

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


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