StructFindValue

Searches recursively through a substructure of nested arrays, structures, and other elements for structures with values that match the search key in the value parameter.

StructFindValue( Top, Key [, Scope ] )

Returns: Array

Argument Description Default
Top
struct, required

structure from which to start search. This parameter requires an object, not a name of an object.

Key
string, required
Scope
string, optional
  • one (default): function returns one matching key
  • all: function returns all matching keys

one

Examples

Member Function

animals = {
	cow: {
		noise: "moo",
		size: "large"
	},
	pig: {
		noise: "oink",
		size: "medium"
	},
	cat: {
		noise: "meow",
		size: "small"
	}
};
// Show all animals
Dump(
	label: "All animals",
	var: animals
);
// Find animal containing value of 'medium'
findMediumAnimal = animals.findValue("medium");
// Show results in findMediumAnimal
Dump(
	label: "Results of animals.findValue(""medium"")",
	var: findMediumAnimal
);

Non-Member Function

animals = {
	cow: {
		noise: "moo",
		size: "large"
	},
	pig: {
		noise: "oink",
		size: "medium"
	},
	cat: {
		noise: "meow",
		size: "small"
	}
};
// Show all animals
Dump(
	label: "All animals",
	var: animals
);
// Find animal containing value of 'medium'
findMediumAnimal = StructFindValue(animals, "medium");
// Show results in findMediumAnimal
Dump(
	label: "Results of StructFindValue(animals, ""medium"")",
	var: findMediumAnimal
);

See also