/**/

main:

    diplom  = "Oktoberfest"
    fnlog = "data/199609.log"

    rule.COUNT = 0

    call error LoadRule(diplom)

    do i = 1 to rule.COUNT
        say "Regel: "rule.i
    end
    say

    exit

error:
parse arg err

    if err = !E_NOERR then return

    say "Fehler: "err

    exit

LoadRule: procedure expose rule. pnoetig
parse arg diplom

    rc = !E_NOERR

    fndip = "data/diplom.dbf"

    founddip = 0

    if open(dip,fndip,"READ") then do
        do forever
            if eof(dip) then leave
            z = readln(dip)
            if z = "" then iterate
            if translate(word(z,1)) = translate(diplom) then do
                founddip = 1
                pnoetig = strip(substr(z,100,49))
                fnrule = "data/"strip(substr(z,150,length(z)))
                if open(rul,fnrule,"READ") then do
                    do forever
                        if eof(rul) then leave
                        z = strip(readln(rul))
                        if z = "" then iterate
                        anz = rule.COUNT
                        anz = anz + 1
                        rule.COUNT = anz
                        rule.anz = z
                    end
                    ok = close(rul)
                end
                else
                    rc = !E_NORULEDBF
            end
        end
        ok = close(dip)
        if founddip = 0 then 
            rc = !E_DIPLOMNOTFOUND
    end
    else
        rc = !E_NODIPLOMDBF

return rc
