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>_itemputnl()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _itemPutNL()
 Place a long number into an Item
------------------------------------------------------------------------------
 C Prototype

     #include "item.api"
     ITEM _itemPutNL(
                      ITEM itemNumber,
                      long lNum
                    )

 Arguments

     itemNumber is the Item into which you want to place the number.  If
     this Item is NULL, _itemPutNL() will create a new Item.

     lNum is the signed long integer number to assign to the Item.

 Returns

     A new signed long item reference containing the numeric passed.

 Description

     The _itemPutNL() function is used to place a numeric long into an Item.
     You should use a long value to represent a number when you know that the
     number will fall within the range of -2,147,483,648 to 2,147,483,647.

     Caution!  Do not assume that the address in itemNumber will be the
     same address returned by _itemPutNL().

 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: _itemGetNL() _itemPutND()

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