Up: Record Library Samples   [Index]


7.19.3.1 Traversing Records

Records may be traversed by keys. Starting from the first to the last:

record r;
text s;

...

if (r_first(r, s)) {
    do {

...

    } while (r_greater(r, s, s));
}

Starting from the last, backwards:

record r;
text s;

...

if (r_last(r, s)) {
    do {

...

    } while (r_less(r, s, s));
}

Traversing may be started at any point.

Traversing a record mapping integers for strings and starting at "mid":

record r;
text s;

s = "mid";
if (r_greaterorequal(r, s, s)) {
    integer a;

    a = r[s];
    do {
	o_form("~: ~\n", s, a);
    } while (rs_n_integer(a, r, s, s));
}