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>_itemgetds()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _itemGetDS()
 Retrieve a date as a character string
------------------------------------------------------------------------------
 C Prototype

     #include "item.api"
     BYTEP _itemGetDS(
                       ITEM itmDate,
                       BYTEP fpBuffer
                     )

 Arguments

     itmDate is the item from which to retrieve a date string.

     fpBuffer is the 8 character buffer to place the date string within.

 Returns

     A zero-terminated string of the format yyyymmdd representing the date
     value contained within the item passed.

 Description

     _itemGetDS() allows you to retrieve the value of a CA-Clipper-level date
     as a character string.  The returned string is a copy of the date, so
     any changes to the string cannot be reflected to the CA-Clipper level if
     the item is a parameter.

     Note:  The date string returned is zero-terminated.

     Warning!  You are responsible for allocating and freeing the buffer
     where the date string is placed.  Note that the recommended destination
     memory address is the stack, since values returned from _itemGetDS()
     will always be 8 characters long.

 Examples

     /*
     *
     * Quarter( dDate ) -> nQuarter
     *
     *
     * Given a date, determines what quarter it lies in
     *
     */

     CLIPPER Quarter( void )
     {
        ITEM itmDate, itmQuarter;
        BYTE sDate[8];               // Date buffer: YYYYMMDD\0

        if ( PCOUNT == 0 )
        {
           _ret();                  // Withhold service!
           return;
        }

        itmQuarter = _itemPutNL( NULL, 0 );
        itmDate = _itemParam( 1 );

        if ( _itemType( itmDate ) == DATE )
        {
           _itemGetDS( itmDate, sDate );

           sDate[6] = NULL;

           if (sDate[4] == '1')
           {
              itmQuarter = _itemPutNL( itmQuarter, 4 );
           }
           else
           {
              switch ( sDate[5] )
              {
                 case '1':
                 case '2':
                 case '3':
                    itmQuarter = _itemPutNL( itmQuarter, 1 );
                    break;

                 case '4':
                 case '5':
                 case '6':
                    itmQuarter = _itemPutNL( itmQuarter, 2 );
                    break;

                 default:
                    itmQuarter = _itemPutNL( itmQuarter, 3 );

              }
           }
        }

        _itemReturn( itmQuarter );
        _itemRelease( itmDate );
        _itemRelease( itmQuarter );

        return;
     }

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


See Also: _itemPutDS()

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