Skip to content

List Get

Summary

  • Internal name: ListGet
  • Category: Collections
  • Purpose: Read the element at a given index from a list variable and store it in an output variable.
  • Task type: Normal

Compatibility

  • Minimum AndroMate version: 1.1.0

  • Maximum AndroMate version: 1.1.0

  • Minimum Android: Android 13 (API 33)

  • Maximum Android tested: Android 16 (API 36)

  • Supported manufacturers:

    • ✅ All manufacturers
  • Required permissions:

    • None

Detailed description

The List Get task reads the string element at position index_input (zero-based) and stores it in the variable value_output. The list itself is not modified.


Input parameters

Parameter Type Required Possible values Android Compatibility AndroMate Compatibility Default
list_variable_input Variable reference Yes Declared variable starting with $, holding a valid list Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0
index_input Integer / Variable Yes Zero-based index; must be 0 ≤ index < size Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 0

Output parameters

Field Type Condition Default
value_output String On success — the element at index_input <ANDROMATE_NULL_VALUE>

Exceptions

Code Exception Name Description
COLLECTION-TASK-001 List Variable Not a List Index is out of bounds — negative or ≥ list size.
COLLECTION-TASK-002 List Variable Name Invalid list_variable_input is empty or does not start with $.
RESOLVE-VAR-005 Resolve ArrayList Error The variable does not contain a valid JSON array string.

Execution flowchart

flowchart TD
    Start([Start ListGet]) --> ResolveList[🔄 Resolve list_variable_input]
    ResolveList --> CheckList{Valid list?}
    CheckList -->|No| E1[❌ RESOLVE-VAR-005]
    CheckList -->|Yes| ResolveIndex[🔄 Resolve index_input]
    ResolveIndex --> CheckBounds{0 ≤ index < size?}
    CheckBounds -->|No| E2[❌ COLLECTION-TASK-001]
    CheckBounds -->|Yes| Get[element = list.get index]
    Get --> SetOutput[💾 result.setOutputStr element\nstored via value_output]
    SetOutput --> Success([✅ StrTaskResult])
    E1 --> Error([❌ Exception])
    E2 --> Error

    style Start fill:#e3f2fd
    style Success fill:#c8e6c9
    style Error fill:#ffcdd2
    style ResolveList fill:#fff9c4
    style ResolveIndex fill:#fff9c4
    style SetOutput fill:#c8e6c9
    style E1 fill:#ffcdd2
    style E2 fill:#ffcdd2

How it works:

  1. Resolve list: Fetches and parses the JSON array string from the execution context
  2. Resolve index: Evaluates index_input — supports $variable references
  3. Bounds check: Raises COLLECTION-TASK-001 if out of bounds
  4. Get element: Reads list.get(index)
  5. Store output: Writes the element into the variable specified by value_output
  6. Result: Returns StrTaskResult

Complete JSON example

{
  "ListGet": [
    {
      "id": "6",
      "title": "Read first element",
      "list_variable_input": "$myList",
      "index_input": "0",
      "value_output": "$firstElement"
    }
  ]
}