samptable

Return a specified value from a table given an associated table-handle variable.


Synopsis

val = samptable(table_handle, [ interp_type, ] index)

Parameters inside the [brackets] are optional.


Description

samptable returns the value at table element index of the table from the table_handle variable. table_handle is instantiated using the maketable scorefile command. The optional interp_type specifier determines if a fractional index will be interpolated between two of the table values, or will be ‘rounded down’ (truncated) to the nearest integer table location.


Arguments


RETURN VALUE

Returns to the script the value at the index (or interpolated between index and index+1) in the table array.


Examples

   table = maketable("literal", "nonorm", 0, 8.00, 8.02, 8.03, 8.05, 8.07)
   tablelength = tablelen(table)

   for (i = 0; i < 10; i = i+1) {
      val = samptable(table, "nointerp", irand(0, tablelength))
   }

val will be set to a different, random value of the table for each iteration of the loop. Setting the optional specifier “nointerp” will guarantee that val will assume values taken directly from the table.


See Also

maketable, modtable, makefilter, copytable, dumptable, tablelen