Watching $lists, Stringlists, and Arraylists

From m204wiki
Revision as of 17:56, 25 April 2023 by Ekern (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

To inspect $lists, Stringlists, and Arraylists, you apply additional $functions or object methods to the $list, Stringlist, or Arraylist variable in the text box above the Watch Window. Otherwise, the Debugger will merely report whether or not these variables have content.

This section describes how to watch individual list items or list counts. Using a related technique, you can display all the list items and their values at once.

To watch $lists, Stringlists, or Arraylists:

$listcnt(listID Gets the number of items in the list
$listinf(listID,subscript) Gets the value of a particular list item.
Where:
  • listID is a $list identifier, most often a Float variable. It must be a simple variable or a constant; it may not be an image item or a %variable array item, for example.
  • subscript is a 1 based list item subscript that identifies the item to watch.

 

  • For Stringlists or Arraylists, specify either of the following in the Entity name input box for the %list Stringlist or Arraylist object variable:
%list:count Gets the number of items in the list
%list:item(num) Gets the value of a particular list item.
Where:
  • %list is a Stringlist or Arraylist object variable.
  • num is a 1 based positive integer that identifies the item to watch. It must be a simple variable or a constant; it may not be an image item or a %variable array item, for example.

For example, here are the results of watching the function specifications $LISTCNT(%G), $LISTINF(%G, 1), $LISTINF(%G, 2), and $LISTINF(%G, 3):

watchList1a  

The contents of the Watch Window, above, result from evaluating the following test program:

INCLUDE LISTTEXT b   %i is float   %g is float   %g = $listnew   %i = 777   $listadd(%g, 'All work and no play')   $listadd(%g, ' makes Jack a dull boy.')   $list_print(%g) end