Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - listitemlen() return the length of a generic list item http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 listitemlen()       Return the length of a generic list item
------------------------------------------------------------------------------
 Declaration
   pick.hdr

 Syntax
   func uint listitemlen extern
   param value _LIST pList, ;
         value uint  uItem

 Arguments
   pList is a list pointer.
   uItem is a list item index.

 Return
   The length of the specified item in bytes.

 Description
   The listitemlen() function retrieves the length of a generic list item.

 Example
   #define EXAMPLE_LIST
   #include example.hdr

   // This example demonstrates the use of a list to store various
   // data types, including string, numeric, and complex structure
   
   typedef struct CUST
      char( 10 ) cName      // member length is 10 + 1 = 11 bytes
      uint       nAge       // member length is 2 bytes
      logical    lPaid      // member length is 2 bytes
   enddef                   // total length is 15 (#defined below)
   
   proc Test_listitemlen
   vardef
      CUST     sCust        // an instance of the structure
      _LIST   pList         // pointer to the list
      char(20) cString
      uint     n            // counter
   enddef
   pList := pickinit()      // allocate list from dynamic memory
   
   // put a structure in the list
   sCust.cName := "Johnnie"              // assign char member
   sCust.nAge  := 31                     // assign numeric member
   sCust.lPaid := .t.                    // assign logical member
   listput( pList, &sCust, sizeof( sCust ) ) // add the structure to the list
   
   // add a string to the list
   cString := "hello"
   listput( pList, &cString, 6 )
   
   // add a number to the list
   n := 234
   listput( pList, &n, sizeof( sCust ) )
   cString := "Force compiler"
   listput( pList, &cString, len( cString ) + 1 )
   
   ? "Lengths:"
   for n := 1 to pickcount( pList )      // display item lengths
      ? listitemlen( pList, n )
   next
   
   ?
   ? "Data:"
   listget( pList, &cString, 4 )         // retrieve a string
   ? cString
   listget( pList, &sCust, 1 )           // retrieve structure
   ? sCust.cName, istr( sCust.nAge ), sCust.lPaid
   listget( pList, &n, 3 )               // retrieve numeric
   ? n
   listget( pList, &cString, 2 )         // retrieve string
   ? cString
   
   pickclear( pList )                    // get back memory
   endproc

   proc main
   Test_listitemlen()
   endproc

See Also: listput()

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