ScriptTap
ArraySegmentScan

Command video guide

ArraySegmentScan

ArraySegmentScan inspects an existing typed array without reading the screen or changing that array. Match its letter, Value Type and scope to the SetVariable declaration. This Script Only is local; Script Thread uses the calling thread scope. Integer, Decimal, Boolean, Hex, String and Time are supported. Hex matching is exact; use ColorClassify for confidence-based color matching.

Start is a one-based original position; Length is a number of positions, not the final index. Both accept Integer literals or prior Integer variables. The range must fit the declared capacity, up to 4096. Forward starts at Start; Reverse starts at the other end of that range. Reported indexes remain original array positions. A zero Length scans nothing and produces no-match outputs.

Where shown, Empty Value defines the typed empty sentinel; unwritten slots are also empty. Active Mask reads a prior Boolean array: only true positions are eligible, and false positions break runs. Found writes a Boolean; Index and Count write Integers. Enable only the outputs needed by later commands. A true mode change clears the old mode-specific settings and destinations, so check them again.

The Intro builds a fresh five-command script with genuine palette drags: declare local Integer array a with capacity eight; ArraySet Bulk writes 0,5,5,0,9,9,9,0; ArraySegmentScan uses First Non-Empty; Display reads i1 for five seconds; PromptMe shows Scanned/Done using its separate Boolean b2.

First Non-Empty returns the first occupied position. With Empty Value 0, the first useful value is 5 at position 2. Found b1 is true, Index i1=2, Value i2=5, and Count i3=1. Display shows 2, not the stored value 5. Follow-up tabs reuse this script.

Watch the walkthrough

Step-by-step guide

  1. Step 01

    Array Segment Scan inspects values already stored in an array. It can find a position, count matching values, or describe a continuous run. It does not read the screen or change the source array. We will build one small script and display a real result.

    ArraySegmentScan step 1: Array Segment Scan inspects values already stored in an array. It can find a position, count matching values, or describe a continuous run. It does not read the screen or change the source array. We will build one small script and display a real result.
  2. Step 02

    Choose New Script, then Blank Script. Open the new script's menu and choose Rename.

    ArraySegmentScan step 2: Choose New Script, then Blank Script. Open the new script's menu and choose Rename.
  3. Step 03

    Pick a name for your script. Select it, close the library, and open the editor from the main overlay.

    ArraySegmentScan step 3: Pick a name for your script. Select it, close the library, and open the editor from the main overlay.
  4. Step 04

    Find Set Variable under Variables. Scroll the palette so the command is higher, then drag it straight across into the script. The scan needs an array to inspect, so this supporting command declares it before the scan runs.

    ArraySegmentScan step 4: Find Set Variable under Variables. Scroll the palette so the command is higher, then drag it straight across into the script. The scan needs an array to inspect, so this supporting command declares it before the scan runs.
  5. Step 05

    Choose Array. Use the local Integer array a with capacity eight, then save. The array letter, type, and scope must agree in the commands that use it.

    ArraySegmentScan step 5: Choose Array. Use the local Integer array a with capacity eight, then save. The array letter, type, and scope must agree in the commands that use it.
  6. Step 06

    Next, open Advanced. Choose Set on the shared Array Get and Set tile, then drag Array Set below the declaration.

    ArraySegmentScan step 6: Next, open Advanced. Choose Set on the shared Array Get and Set tile, then drag Array Set below the declaration.
  7. Step 07

    Use array a, Integer, and This Script Only. Choose Bulk so we can give the eight positions an easy-to-recognize pattern.

    ArraySegmentScan step 7: Use array a, Integer, and This Script Only. Choose Bulk so we can give the eight positions an easy-to-recognize pattern.
  8. Step 08

    Enter the position and value pairs, then choose Paste Rows. Positions one, four, and eight contain zero. Positions two and three contain five. Positions five through seven contain nine.

    ArraySegmentScan step 8: Enter the position and value pairs, then choose Paste Rows. Positions one, four, and eight contain zero. Positions two and three contain five. Positions five through seven contain nine.
  9. Step 09

    Each pair becomes an enabled row. Review the first and last positions, then save. This setup gives the scan both empty values and repeated groups to work with.

    ArraySegmentScan step 9: Each pair becomes an enabled row. Review the first and last positions, then save. This setup gives the scan both empty values and repeated groups to work with.
  10. Step 10

    Drag Array Segment Scan below Array Set, then open it. The setup must run before the scan.

    ArraySegmentScan step 10: Drag Array Segment Scan below Array Set, then open it. The setup must run before the scan.
  11. Step 11

    Use In chooses This Script Only or Script Thread. Keep the same scope as the declaration. This example uses This Script Only.

    ArraySegmentScan step 11: Use In chooses This Script Only or Script Thread. Keep the same scope as the declaration. This example uses This Script Only.
  12. Step 12

    Choose array a. Value Type must match its declaration. Integer, Decimal, Boolean, Hex, String, and Time arrays are supported. Hex comparisons are exact; Color Classify is the command for confidence-based color matching.

    ArraySegmentScan step 12: Choose array a. Value Type must match its declaration. Integer, Decimal, Boolean, Hex, String, and Time arrays are supported. Hex comparisons are exact; Color Classify is the command for confidence-based color matching.
  13. Step 13

    Start is the first position, counting from one. Length is how many positions to inspect, not the last index. Set Start to one and Length to eight. These fields also accept previously written Integer variables. The range must fit the declared capacity.

    ArraySegmentScan step 13: Start is the first position, counting from one. Length is how many positions to inspect, not the last index. Set Start to one and Length to eight. These fields also accept previously written Integer variables. The range must fit the declared capacity.
  14. Step 14

    Forward examines this range from its beginning. Reverse starts at the other end. Output indexes still refer to the original array positions. We will keep Forward.

    ArraySegmentScan step 14: Forward examines this range from its beginning. Reverse starts at the other end. Output indexes still refer to the original array positions. We will keep Forward.
  15. Step 15

    Choose First Non-Empty. It finds the first occupied position in the chosen direction. Changing scan modes clears settings that belong to the previous mode, so check the settings and outputs again.

    ArraySegmentScan step 15: Choose First Non-Empty. It finds the first occupied position in the chosen direction. Changing scan modes clears settings that belong to the previous mode, so check the settings and outputs again.
  16. Step 16

    Set Empty Value to zero. An unwritten position is empty, and a stored value equal to this setting is also treated as empty. In this example, zero is a marker, not a useful item.

    ArraySegmentScan step 16: Set Empty Value to zero. An unwritten position is empty, and a stored value equal to this setting is also treated as empty. In this example, zero is a marker, not a useful item.
  17. Step 17

    Active Mask optionally uses a previously prepared Boolean array. Only positions whose mask is true are eligible. A false position also breaks a run. We do not need a mask here, so leave it off.

    ArraySegmentScan step 17: Active Mask optionally uses a previously prepared Boolean array. Only positions whose mask is true are eligible. A false position also breaks a run. We do not need a mask here, so leave it off.
  18. Step 18

    Found Output writes a Boolean result: true when something was found, false otherwise. Enable it and use b one. A green check means on; a dash means off.

    ArraySegmentScan step 18: Found Output writes a Boolean result: true when something was found, false otherwise. Enable it and use b one. A green check means on; a dash means off.
  19. Step 19

    Index Output writes the matching position as an Integer. Enable it and use i one. This is the result our Display command will show.

    ArraySegmentScan step 19: Index Output writes the matching position as an Integer. Enable it and use i one. This is the result our Display command will show.
  20. Step 20

    Value Output writes the matching value in the array's type. Enable it and use i two. Our array is Integer, so this destination is also Integer.

    ArraySegmentScan step 20: Value Output writes the matching value in the array's type. Enable it and use i two. Our array is Integer, so this destination is also Integer.
  21. Step 21

    Count Output uses an Integer destination. Enable it and use i three. First Non-Empty returns one when it finds an item; counting modes use this output for the full count.

    ArraySegmentScan step 21: Count Output uses an Integer destination. Enable it and use i three. First Non-Empty returns one when it finds an item; counting modes use this output for the full count.
  22. Step 22

    Now drag Display below the scan. It makes the numerical result visible, rather than leaving it only in a variable.

    ArraySegmentScan step 22: Now drag Display below the scan. It makes the numerical result visible, rather than leaving it only in a variable.
  23. Step 23

    Choose Variable as the text source and enter i one. We are displaying the position, not the array value stored there.

    ArraySegmentScan step 23: Choose Variable as the text source and enter i one. We are displaying the position, not the array value stored there.
  24. Step 24

    Choose an area away from the main overlay. The area icon opens a visual selector. If Android asks, allow screen capture. Here, go back and use the area label to enter exact boundaries: left one hundred, top three hundred, right four hundred forty, and bottom six hundred.

    ArraySegmentScan step 24: Choose an area away from the main overlay. The area icon opens a visual selector. If Android asks, allow screen capture. Here, go back and use the area label to enter exact boundaries: left one hundred, top three hundred, right four hundred forty, and bottom six hundred.
  25. Step 25

    Set Lifespan to five thousand milliseconds, then save. This leaves the actual result visible for five seconds.

    ArraySegmentScan step 25: Set Lifespan to five thousand milliseconds, then save. This leaves the actual result visible for five seconds.
  26. Step 26

    Finally, drag Prompt Me below Display. Its Scanned header and Done button provide a clear completion confirmation.

    ArraySegmentScan step 26: Finally, drag Prompt Me below Display. Its Scanned header and Done button provide a clear completion confirmation.
  27. Step 27

    Add one Done button and use b two for its output. This is separate from the scan's Found result in b one. Save the prompt.

    ArraySegmentScan step 27: Add one Done button and use b two for its output. This is separate from the scan's Found result in b one. Save the prompt.
  28. Step 28

    The script declares the array, fills its eight values, scans it, displays the index, and confirms completion. The first non-empty value is five at position two.

    ArraySegmentScan step 28: The script declares the array, fills its eight values, scans it, displays the index, and confirms completion. The first non-empty value is five at position two.
  29. Step 29

    Close the editor and expand the main overlay.

    ArraySegmentScan step 29: Close the editor and expand the main overlay.
  30. Step 30

    When the script is complete, simply use the Play button in the main overlay.

    ArraySegmentScan step 30: When the script is complete, simply use the Play button in the main overlay.
  31. Step 31

    Display shows two: the original position of the first non-empty value. The scan has not changed the array.

    ArraySegmentScan step 31: Display shows two: the original position of the first non-empty value. The scan has not changed the array.
  32. Step 32

    The Scanned prompt confirms that the following command was reached. Tap Done to finish.

    ArraySegmentScan step 32: The Scanned prompt confirms that the following command was reached. Tap Done to finish.
  33. Step 33

    Use First Non-Empty to locate the next useful item. The other tabs reuse this script to demonstrate empty positions, exact matches, counts, and runs.

    ArraySegmentScan step 33: Use First Non-Empty to locate the next useful item. The other tabs reuse this script to demonstrate empty positions, exact matches, counts, and runs.