traverse_dict

Definition: traverse_dict(integer rid, object user_data=0, integer tid=1, bool rev=false)
Description: Perform an in-order traversal of the dictionary, invoking the specified routine for each {key,data} pairing.

rid: routine_id of a function that accepts three parameters, called for each entry.
user_data: any additional data that might be required by rid.
tid: a result from new_dict(), or if omitted it uses the one common dictionary.
rev: if true, the traversal is made from the highest key to the lowest key.
Comments: The specified routine should be a function that accepts three parameters: key, data, and user_data, and should return 1 to continue the traversal, or 0 to terminate it.

The ordering is case-sensitive. If a case-insensitive ordering is required, the key values as passed to setd() [etc] should be passed through either upper() or lower() and if needs be a copy of the original case included somewhere in data.

The use of a named parameter when setting the rev flag is recommended, to make the intent clear and the code easier to read.
Example:
function visitor(object key, object data, object /*user_data*/)
    ?{key,data}
    return 1
end function

setd("key","data")
setd("key2","data2")

traverse_dict(routine_id("visitor"))
See Also: setd, upper, lower, routine_id, traverse_dict_partial_key