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>_itemreturn()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _itemReturn()
 Return an Item to CA-Clipper
------------------------------------------------------------------------------
 C Prototype

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

 Arguments

     itemRet 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, and therefore,
     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.  Version 1.00
     *
     */

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

        BYTEP  cStringP;
        BYTE   cFindMe;

        ITEM   itemString, itemFindMe, itemRet;

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

        itemRet    = _itemPutNL( NULL, 0 );
        itemString = _itemParam( 1 );
        itemFindMe = _itemParam( 2 );

        if ( (_itemType( itemString ) == CHARACTER) &&
              (_itemType( itemFindMe ) == CHARACTER) )
        {
           _itemCopyC( itemFindMe, &cFindMe, 1 );

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

           uiLen = _itemCopyC( itemString, cStringP, NULL );

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

           _xvunlock( vmhString );
           _xvfree( vmhString );

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

        }

        _itemReturn( itemRet );

        _itemRelease( itemRet );
        _itemRelease( itemString );
        _itemRelease( itemFindMe );

        return;
     }

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


See Also: _itemParam() _itemRelease()

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