Read a Storage Slot
easy
Reads a part ID from a selected storage slot and reports an invalid selection.
What it teaches
A numbered storage rack is a list: index 0 is its first slot. The array belongs to the program using this one: read it without changing it, check both index bounds, and distinguish an empty slot from an invalid selection. An indexed move or assignment supplies the selected value.
Parameters
| Tag | Direction | Type | Default | Description |
|---|---|---|---|---|
| In_Index | Input | DINT | 0 | Zero-based slot to inspect |
| Out_PartId | Output | DINT | 0 | Part ID, or 0 for an invalid index |
| Sts_Valid | Output | BOOL | 0 | 1 when the index is within the rack |
| Ref_Slots | InOut | DINT[8] | — | Read-only storage slots; 0 means empty |
Required behavior
- Every scan, a valid In_Index from 0 through 7 returns Ref_Slots[In_Index] and Sts_Valid = 1.
- For any other index, return Out_PartId = 0 and Sts_Valid = 0. An empty slot is a valid selection with part ID 0.
- Never change Ref_Slots.