Englisch version   Deutsche Version


Version Adjustments
1 (2019-01-12) Initial version
1.1 (2019-01-14) Bug in AddMsg fixed.
1.2 (2024-01-06) Package name changed (all lower case) due to problems with the current AI2 version.
This change makes this version incompatible with the previous one.

Migration instructions from version 1.x to 2.0:

  1. Create a backup copy (Save project as ...).
  2. Import the new version of the extension into the project.
  3. Export the project (.aia file, Export selected project (.aia) to my computer).
  4. Open the file with the appropriate software (rename to .zip if necessary).
  5. Delete all non-matching entries for UrsLimitedStringList in the assets/external_comps folder (de.ullisroboterseite.urslimitedstringslist is retained, all letters lower case!).

Motivation

When working with MIT App Inventor 2, debugging, especially debugging events, is quite tedious. The "limited string list" presented here is very well suited for collecting debug messages and displaying the latest of them. If a newly recorded message exceeds the capacity of the list, the first entry is removed. The capacity is adjustable.

The highlight of this list, however, are the two methods ToString and ToReverseString. They return the entire contents of the list as a single multiline string, one row for each list item.

Download

The ZIP archive UrsLimitStringList for downloading. The archive contains the source code and the compiled binary and a sample project to upload to the App Inventor.

Usage

Block Funktion Anmerkung
Add  Adds a new line to the end of the list. If this addition exceeds the capacity of the list, the first item is removed from the list.
Separator Gets or sets the separator string for AddMsg. Default value is ":␣". Required for AddMsg (next block).
AddMsg Adds a new line to the end of the list.. Line
   <Sender><Separator><Text>
is added.
Clear The content of the list is deleted.  
Item Gets the item with the number specified in Index. The numbering starts with 1. If the Index entry is outside the valid range [ 0..Length ], an empty string is returned.
First/Last Gets the first or last item in the list. If the list is empty, an empty string is returned.
Length Gets the number of items in the list.  
IsEmpty Returns a boolean value indicating whether the list contains items. Return values are true or false.
ToString Gets the entire contents of the list as a single multi-line string. For each list item, a single row is generated. ToString returns the rows in the order they had been added. ToReverseString does this in reverse order. The individual lines are separated by "\n".
Limit  Gets or sets the capacity of the list. Values < 1 are ignored.
Limit  The initial capacity can also be set in the Designer. Likewise the separator string.  
Events  These events are triggered when the corresponding method of the list block is called.

Each event then fires ContentChanged.
 
ContenChanged The ContentChanged event is fired when the content of the list changes. ContentChanged fires after the individual events.
EventType Data Message
0: Line added Text "Line added: <Text>"
1: Limit changed Limit "Limit set to <Limit>"
2: List was cleared "" "List was cleared"

Example App

Screenshots of the App

Screenshot   Screenshot

 

Procedure FillProperties

This procedure transfers the properties of the list to the screen components. This procedure is called whenever something has changed.

FillProperties

Add lines to the list

Add items   cmdAdd adds the text from the input field tbxAdd above to the list.

Add items

Clear the list

Clear the list   cmdClear clears the list.

Clear the list

Set the capacity of the list

Set capacity   cmdLimit defines a new capacity of the list depending on the input field tbxLimit.

Set capacity

Set display order

Define display order   cbxReverseOrder defines the order of the list elements in the lower display field lblConent.

 

Define display order

Tools

For developing own extensions I gathered some tips: AI2 FAQ: Develop Extensions.