Loop Through All Record Types (code snippet)

Description

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

Requires: None

Code

RecordTypes.fh_lua
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