mxaccesscli: document <arrayAttr>[] as the bulk-array read syntax

Empty square brackets — `<obj>.<arrayAttr>[]` — are the supported
MxAccess reference form for fetching a whole array as a single value.
Verified live:

  mxa read 'MESReceiver_001.MoveInPartNumbers[]' --llm-json
  -> ok=true, value=["", "11111", "", ..., "15", ...] (50 elements,
     quality=192, MxCategoryOk)

The bare reference without brackets continues to return
MxCategoryCommunicationError, Detail=1003 — that's a real proxy-side
rejection, not a CLI bug. Documented separately so the matrix shows
both the working syntax and the failing one.

docs/usage.md:
- Type matrix gains a "bulk array read via []" row () and a
  "bare reference" row (, kept for reference).
- "Reading arrays" section rewritten around the two reference
  shapes — `[]` for whole arrays, `[N]` for elements (1-based,
  N <= NumElements).
- Adds a "Discovering array length" note pointing at grdb's
  attributes.sql array_dimension column.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-05-03 21:02:28 -04:00
parent cc1ce05f96
commit e9e37385aa
+44 -10
View File
@@ -131,8 +131,9 @@ Verified end-to-end against the live `ZB` galaxy (System Platform 2017 Express,
| `MxQualifiedStruct` (14) | | | | Access via dotted member names: `<obj>.<struct>.<field>`. |
| `MxInternationalizedString` (15) | ❓ | ❓ | (likely string) | No accessible instance. |
| `MxBigString` (16) | ❓ | ❓ | JSON string | No accessible instance. |
| **Array (any type), bulk read** | | | — | `MxAccess.AddItem(<arrayRef>)``MxCategoryCommunicationError, Detail=1003`. Bulk array reads are not supported by this LMX client API. |
| **Array element by index** | | | scalar of element type | Reference syntax `<obj>.<arrayAttr>[<n>]`. **1-based** indexing. Verified on `MESReceiver_001.MoveInPartNumbers[2]` (String[]). `[0]` is invalid. |
| **Array (any type), bulk read** | | | JSON array of element type | Reference syntax `<obj>.<arrayAttr>[]`**empty square brackets**. Verified on `MESReceiver_001.MoveInPartNumbers[]` (String[50]) and `MoveOutWorkOrderNumbers[]`. Returns the entire array as a single value with `MxCategoryOk`. |
| **Array (bare reference)** | | | — | The plain `<obj>.<arrayAttr>` (no brackets) returns `MxCategoryCommunicationError, Detail=1003`. Use `[]` instead. |
| **Array element by index** | ✅ | ✅ | scalar of element type | Reference syntax `<obj>.<arrayAttr>[<n>]`. **1-based**, runs from `[1]` to `[NumElements]`. `[0]` is invalid. |
Legend: ✅ verified live, ⚠️ wiring present but no live instance to write, ❓ wiring present but no live instance found, ❌ not supported by MxAccess at this layer, not applicable.
@@ -160,18 +161,51 @@ Common failure shapes:
## Reading arrays
MxAccess does not return array attributes as a single rowset. Bulk `AddItem("<obj>.<arrayAttr>")` returns `MxCategoryCommunicationError, Detail=1003`. Read elements individually:
MxAccess accepts **two** reference forms for arrays — pick by what you need:
### Whole array — `<obj>.<arrayAttr>[]` (empty brackets)
```powershell
mxa read 'MESReceiver_001.MoveInPartNumbers[1]' \
'MESReceiver_001.MoveInPartNumbers[2]' \
'MESReceiver_001.MoveInPartNumbers[3]' \
--llm-json
mxa read 'MESReceiver_001.MoveInPartNumbers[]' --llm-json
```
- Array indices are **1-based** (`[1]`, `[2]`, …). `[0]` is invalid and returns a configuration error.
- The CLI does not (yet) auto-discover the array length; combine with [`../../grdb/queries/attributes.sql`](../../grdb/queries/attributes.sql) (`array_dimension` column) to know how many elements to fetch.
- Writing an element uses the same indexed reference: `mxa write '<obj>.<attr>[N]' <value>`.
Returns the full array as a single JSON value:
```jsonc
{
"tag": "MESReceiver_001.MoveInPartNumbers[]",
"ok": true,
"value": ["", "11111", "", "", /* ... 50 elements total ... */],
"quality": 192,
"statuses": [{"Success":-1,"Category":"MxCategoryOk", ...}]
}
```
The array is fixed-length (sized at deploy time per the template's `array_dimension`). Empty string elements are unset slots, not gaps.
### Single element — `<obj>.<arrayAttr>[N]`
```powershell
mxa read 'MESReceiver_001.MoveInPartNumbers[2]' --llm-json
```
Indices are **1-based**: `[1]` is the first element, `[NumElements]` is the last. `[0]` is invalid. Single-element reads are also writeable: `mxa write '<obj>.<attr>[N]' <value>`.
### What does *not* work
```powershell
mxa read 'MESReceiver_001.MoveInPartNumbers' # bare ref, no brackets
# → MxCategoryCommunicationError, Detail=1003
```
The plain reference (no `[]`, no `[N]`) is rejected by the proxy. Always include the brackets — empty for whole-array, indexed for element.
### Discovering array length
The CLI doesn't (yet) auto-discover element count. Two ways to find it:
1. Read with `[]` and count the returned values.
2. Query the Galaxy Repository's [`../../grdb/queries/attributes.sql`](../../grdb/queries/attributes.sql) — the `array_dimension` column reports the configured size from the template.
## Picking a tag for a smoke test