Loop Through All Record Types

Provides an iterator to use with the for loop to process all record types. Can be used in conjunction with Code Snippet Loop Through Records.

Requires: None

Code

function recordtypes()
    local t = 0
    local m = fhGetRecordTypeCount()
    return function()
        t = t + 1
        if t <= m then
            return fhGetRecordTypeTag(t)
        end
    end
end

 

Usage

    for type in recordtypes() do
        for pi in records(type) do
            print(fhGetDisplayText(pi))
        end
    end