SampleValues()

Summary

Samples the values of the specified field and returns the specified number of unique values.

Syntax

vals = SampleValues(string field_spec, integer num_unique, integer num_scanned, array options)

Argument Contents
field_spec A field spec
num_unique Number of unique values to return
num_scanned Maximum number of records to scan; 1000 is used if num_scanned is greater than 1000

No options are currently supported.

Returns

An array of unique values.

Notes

  • The records are read in natural order.

  • The returned array will be shorter than num_unique if not enough unique values are found in the first num_scanned records.

  • If a missing value is encountered among the scanned records, a null will be the first element of the returned array. Other elements in the returned array are in increasing order of occurrence.

  • SampleValues() displays a progress bar when scanning 500 or more records. To add a Cancel button to the progress bar, precede the function call with an "on escape" clause. For more information, see Error Handling.

Example

Vals = SampleValues("Population", 20, 200,)

Error Codes

Error Type Meaning
Error The input field specification is ambiguous
Escape The user clicked Cancel
NotFound The input field does not exist

See Also

Function Summary
GetFieldValues() Reads the values of one or more fields in any number of views
GetRecordValues() Reads the values of one or more fields for a record in a view