[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
_itemNew()
Creates a NIL or empty item
------------------------------------------------------------------------------
C Prototype
#include "item.api"
ITEM _itemNew(
ITEM itmNull
)
Arguments
itmNull is an item that should always be NULL.
Returns
A new item of undefined (NIL) type.
Description
The _itemNew() function allows you to create a NIL item to use as a
return value.
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
#include "clipdefs.h"
#include "extend.api"
#include "item.api"
#include "fm.api"
HIDE ITEM near _xMakeSub( USHORTP apSize, USHORT dims );
/*
*
* MYARRAY()
*
* Just like ARRAY()!
*/
CLIPPER MYARRAY(void)
{
ITEM arrayP, elementsP;
SHORT i;
BOOL check;
USHORT pcount = PCOUNT;
USHORTP apSize;
/* Check parameters - must be at least one and all */
/* NUMERIC */
if ( pcount )
{
/* CAUTION: _xgrab() will cause VM IE if there isn't */
/* enough memory */
apSize = (USHORTP)_xgrab( pcount * sizeof( USHORT ) );
/* store the parameters into apSize[] in */
/* reverse order. */
for (i = 0; i < pcount; i++)
{
elementsP = _itemParam( pcount-i );
check = _itemType( elementsP ) == NUMERIC &&
( apSize[i] =
(USHORT)_itemGetNL( elementsP ) ) <= 4096;
_itemRelease( elementsP );
if (!check)
break;
}
/* If all of the parameters check out ...*/
if( check )
{
arrayP = _xMakeSub( apSize, pcount );
_itemReturn ( arrayP );
_itemRelease( arrayP );
}
else
{
_itemRelease( _itemReturn( _itemNew( NULL ) ) ); }
_xfree( apSize );
}
}
HIDE ITEM near _xMakeSub( USHORTP apSize, USHORT dims )
{
ITEM arrayP;
ITEM tempP;
USHORT i;
arrayP = _itemArrayNew( apSize[ --dims ] );
if ( dims )
{
for (i = 1; i <= apSize[ dims ]; i++)
{
tempP = _xMakeSub( apSize, dims );
_itemArrayPut( arrayP, i, tempP );
_itemRelease( tempP );
}
}
return (arrayP);
}
Files Library is CLIPPER.LIB, header file is Item.api.
See Also:
_itemArrayNew()
_itemRelease()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson