<<one of>> index generator. The compiler generates an anonymous instance of this class for each <<one of>> list in string, setting the property 'numItems' to the number of items in the list, and 'listAttrs' property to a string giving the sequence type. The compiler generates a call to getNextIndex() within the string to get the next index value, which is an integer from 1 to numItems.

class OneOfIndexGen :   object

Superclass Tree   (in declaration order)


Subclass Tree  


Global Objects  


Summary of Properties  

idx_  listAttrs  lst_  numItems 

Summary of Methods  




current position in the list

List attributes. This is a string with a comma-delimited list of tokens describing the treatment on the list for each fetch. The first call to getNextIndex() takes the first token off the list and generates an appropriate return value, possibly queuing up a list of future values. The next call to getNextIndex() reads from the queue. Once the queue is exhausted, the next call takes the second token off the attribute list and repeats the process. Once the attribute list is down to one token, we don't remove the token, but simply repeat it forever.

For example, 'seq,rand' runs through the entire list in sequence once, then generates independently random values from then on. 'shuffle,stop' runs through the list once in shuffled order, then repeats the last pick from the shuffled list forever.

The individual attribute values are:

rand - pick an item at random, independently of past selections.

rand-norpt - pick an item at random, but don't pick the single most recent item chosen, to avoid repeating the same thing twice in a row.

rand-wt - pick an item by random, weighting the items with decreasing probabilities. The last item is given relative weight 1, the second to last weight 2, the third to last weight 3, etc. In other words, the nth item from the end of the list is n times as likely to be picked as the last item. The picks are independent.

seq - run through the items in sequence (1, 2, ... numItems).

shuffle - run through the list in a shuffled order.

shuffle2 - shuffle the list into a random order, but only run through half before reshuffling

stop - repeat the previous selection forever. (This should only be used as the second or later attribute in the list, since it depends on a prior selection being made.)

generated list

number of list items


getNextIndex ( )_main.t[1315]

Get the next index value. Returns an integer from 1 to numItems. The algorithm for choosing the index depends on the list type, as defined by listAttrs.

TADS 3 Library Manual
Generated on 5/16/2013 from TADS version 3.1.3