fieldName

fieldName (schema ordinal -- itemName)

Inputs

Outputs

Returns the stored name for one selected item ordinal in the dereferenced Struct schema. Unnamed items return the empty Text "".

Only the schema participates. Current value contents do not participate.

The ordinal input is dereferenced and must be known at compile time. fieldName preserves the name at the specified ordinal. Repeated names remain repeated and empty names remain empty.

fieldName is therefore not an inverse of fieldIndex when names repeat or are empty, because fieldIndex collapses all matches to the last matching ordinal.

Behavior

Example

{} 0 {} [
  mixed: { 1 "" def 2 "" def 3 "x" def 4 "x" def };

  "-- fieldName keeps each ordinal separate --" printCompilerMessage
  mixed 0 fieldName printStack _:;
  mixed 1 fieldName printStack _:;
  mixed 2 fieldName printStack _:;
  mixed 3 fieldName printStack _:;

  "-- fieldIndex collapses to the last match --" printCompilerMessage
  mixed "" fieldIndex printStack _:;
  mixed "x" fieldIndex printStack _:;

  "-- Tuple items are unnamed --" printCompilerMessage
  (1 FALSE) 0 fieldName printStack _:;
  (1 FALSE) 1 fieldName printStack _:;

  0
] "main" exportFunction

Expected Output During Compilation

-- fieldName keeps each ordinal separate --
""
""
"x"
"x"
-- fieldIndex collapses to the last match --
1
3
-- Tuple items are unnamed --
""
""

See also