fieldIndex (schema itemName -- ordinal)schema: Value or Ref whose dereferenced schema is Struct and whose item names are searched by itemName.itemName: Known non-NIL Text item name used for selection.ordinal: Known Int32 ordinal of the selected item.Returns the selected item ordinal for a known, non-NIL Text item name in the dereferenced Struct schema.
Only the schema participates. Current value contents do not participate.
fieldIndex follows last-match name-selection rules. It therefore returns one selected ordinal, not every matching ordinal. A successful result is always a valid selected-item ordinal in the range 0 through itemCount - 1.
For Dict, that selected ordinal matches the same last-match field rule used by name-based field selection. Use fieldName to preserve the exact stored name at one ordinal and has for presence-only testing.
itemName is selected."" also matches unnamed items and selects the last unnamed item when one is present."" is valid, and it selects the last item."".{} 0 {} [
mixed: { 1 "" def 2 "" def 3 "x" def 4 "x" def };
"-- fieldIndex returns the last match --" printCompilerMessage
virtual emptyKey: mixed "" fieldIndex;
emptyKey printStack _:;
mixed emptyKey fieldName printStack _:;
virtual xKey: mixed "x" fieldIndex;
xKey printStack _:;
mixed xKey fieldName printStack _:;
"-- earlier matches still exist --" printCompilerMessage
mixed fieldCount printStack _:;
mixed 0 fieldName printStack _:;
mixed 2 fieldName printStack _:;
"-- Tuple unnamed item --" printCompilerMessage
virtual tupleKey: (1 FALSE) "" fieldIndex;
tupleKey printStack _:;
(1 FALSE) tupleKey fieldName printStack _:;
0
] "main" exportFunction
-- fieldIndex returns the last match --
1
""
3
"x"
-- earlier matches still exist --
4
""
"x"
-- Tuple unnamed item --
1
""
fieldCount builtin (schema -- itemCount) Schema item count and valid ordinal-range upper bound.fieldIsRef builtin (schema ordinal -- isRefLike) Ref-like test for one selected item schema.fieldIsVirtual builtin (schema ordinal -- hasNoStorage) No-storage test for one selected item.fieldName builtin (schema ordinal -- itemName) Ordinal-to-name lookup that preserves the stored name at one selected ordinal.has builtin (schema itemName -- hasName) Known-name presence test that does not choose an ordinal.schemaName builtin (schema -- reportedName) Reported name of the dereferenced schema.