ItemCount

 (Available in 00 TS Tools(Base) - TS_Tools_PointerSafe)

Purpose

Set the 'ItemCount'

Syntax

oPointerSafe:ItemCount:=10

Arguments

dwItemCount
DWORD

Description

Set the 'ItemCount', this value is provided for the application programmer and can be used to indicate the actual number of stored data items. The methods 'ItemNext()', 'ItemPrevious()', 'ItemFirst()' and 'ItemLast()' can be used to iterate the 'array' of data items.

Returns

dwItemCount

Example

METHOD UsingThePointerSafe( ) CLASS MyObject
LOCAL oPointerSafe AS TS_PointerSafe
LOCAL pItem AS PTR
   oPointerSafe:=TS_PointerSafe{ SELF, 10, _SIZEOF( _WinGUID ) }
   oPointerSafe:ItemAdd( TS_GUID_IDispatch( ) )
   oPointerSafe:ItemAdd( TS_GUID_IUnknown( ) )
   oPointerSafe:ItemAdd( TS_GUID_ITypeInfo( ) )
   IF oPointerSafe:ItemLocate( TS_GUID_ITypeInfo( ) )
      oPointerSafe:ItemDel( oPointerSafe:ItemIndex )
   END
   IF !oPointerSafe:ItemLocate( TS_GUID_ITypeInfo( ) )
      oPointerSafe:ItemAdd( oPointerSafe:ItemIndex )
   END
   oPointerSafe:ItemFirst( )
   WHILE pItem<>NULL_PTR
      IF pItem<>NULL_PTR
         SELF:UseItem( pItem )
      END
      pItem:=oPointerSafe:ItemNext( )
   END
   oPointerSafe:ItemLast( )
   WHILE pItem<>NULL_PTR
      IF pItem<>NULL_PTR
         SELF:UseItem( pItem )
      END
      pItem:=oPointerSafe:ItemPrevious( )
   END
   oPointerSafe:ItemFirst( TRUE )
   WHILE oPointerSafe:ItemNext( )<>NULL_PTR
      SELF:UseItem( oPointerSafe:ItemPTR )
   END
   oPointerSafe:ItemLast( TRUE )
   WHILE oPointerSafe:ItemPrevious( )<>NULL_PTR
      SELF:UseItem( oPointerSafe:ItemPTR )
   END
RETURN SELF

Source

ASSIGN ItemCount( dwItemCount AS DWORD ) AS DWORD PASCAL CLASS TS_PointerSafe
   TSTrace Enter
   IF Between( dwItemCount, 0, SELF:_ItemMax )
      SELF:_ItemCount:=dwItemCount
   ELSE
      TSTrace Warning "!Between(dwItemCount,0,SELF:_ItemMax)"
   END
   dwItemCount:=SELF:_ItemCount
   TSTrace Leave
RETURN dwItemCount