Data Dictionary report. Indexes

For more information about metaschema see Gus's Monograph
/* _index.p.
This program will show you all your indexes like in DataDict Reports.

05/05/96 Dmitri Levinl
*/
define variable V-IND  like _INDEX._INDEX-NAME  no-undo.
define variable V-FILE like _FILE._FILE-NAME    no-undo.
define variable C1     as   character           no-undo.
define variable C2     as   character           no-undo.

form
    V-FILE
    validate(can-find(_FILE where _FILE._FILE-NAME = input V-FILE),
        "Incorrect Table Name")
    help "Press '?' for browse tables"
    with frame main.

on "HELP" of V-FILE do:
    hide frame main.
    {help-br.i 
        &TABLE=_FILE 
        &FIELD=_FILE-NAME 
        &TYPE=char
        &ASSGN=_FILE-NAME 
        &OUT=V-FILE
        &INIT="input V-FILE"
        &LABEL="label ""Table Name"""
    }
    disp V-FILE with frame main.
    view frame main.
end.

form
    C1 format "x" no-labels at 1
    C2 format "x" no-labels at 5
    _INDEX._INDEX-NAME 
    _INDEX._NUM label ""
    _FIELD._FIELD-NAME
    with frame xyz.

repeat: 
    update V-FILE with frame main
        editing:
            readkey.
            if keylabel(lastkey) = "?" then do:
                hide frame main.
                {help-br.i 
                    &TABLE=_FILE 
                    &FIELD=_FILE-NAME 
                    &TYPE=char
                    &ASSGN=_FILE-NAME 
                    &OUT=V-FILE
                    &INIT="input V-FILE"
                    &LABEL="label ""Table Name"""
                }
                disp V-FILE with frame main.
                view frame main.
                if V-FILE <> ? then do:
                    find _FILE where _FILE._FILE-NAME = V-FILE no-lock.
                    apply "RETURN" to V-FILE.
                end.
            end.
            else
                apply lastkey.
        end. /* editing */

    hide frame main no-pause.

    find _FILE where
        _FILE._FILE-NAME = V-FILE 
        no-lock.

    for each _INDEX of _FILE no-lock:
        for each _INDEX-FIELD of _INDEX no-lock:
            find _FIELD of _INDEX-FIELD no-lock.

            if _INDEX._ACTIVE then do:
                if recid(_INDEX) eq _FILE._PRIME-INDEX then C1 = "p".
                else C1 = "".
                if _INDEX._WORDIDX = 1 then C2 = "W".
                else
                if _INDEX._UNIQUE then C2 = "u". 
                else C2 = "".
            end.
            else do:
                assign C1 = "N" 
                       C2 = "A".
            end.

            display
                C1                   when _INDEX-NAME <> V-IND  
                C2                   when _INDEX-NAME <> V-IND  
                _INDEX._INDEX-NAME   when _INDEX-NAME <> V-IND  
                _INDEX._NUM label "" when _INDEX-NAME <> V-IND  
                _FIELD._FIELD-NAME
                 with down frame xyz.
                 down with frame xyz.
            V-IND = _INDEX-NAME.
        end. /* for each _INDEX-FIELD */
    end. /* for each _INDEX */
    clear frame MAIN all.
end. /* repeat */