Data Dictionary report. Tables and Fields

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

07/09/96 Dmitri Levin
*/
define variable V-FIELD like _FIELD._FIELD-NAME              no-undo.
define variable V-FILE  like _FILE._FILE-NAME                no-undo.
define variable V-PROG-NAME as char                          no-undo.

form
    V-FILE
    help "Press ? for browse tables"
    validate(can-find(_FILE where _FILE._FILE-NAME = input V-FILE),
        "Incorrect Table Name")
    V-FIELD
    help "Press ? for browse fields"
    validate(can-find(_FIELD where _FIELD._FILE-RECID = recid(_FILE) and
        _FIELD._FIELD-NAME = input V-FIELD),
        "Incorrect Field Name")
    with frame main side-labels.

on "HELP" of V-FILE do:
    disable all with frame main.
    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.
    enable all with frame main.
    if V-FILE <> ? then do:
        apply "TAB" to self.
    end.
    view frame main.
end.

on "HELP" of V-FIELD do:
    disable all with frame main.
    hide frame main.
    {help-br.i 
        &TABLE=_FIELD 
        &WHERE="_FIELD._FILE-RECID = recid(_FILE)" 
        &FIELD=_FIELD-NAME 
        &FIELD1=_Data-Type
        &TYPE=char
        &ASSGN=_FIELD-NAME 
        &OUT=V-FIELD
        &INIT="input V-FIELD"
        &LABEL="label ""Field Name"""
    }
    disp V-FIELD with frame main.
    enable all with frame main.
    view frame main.
    apply "return" to self.
end.

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:
                    apply "RETURN" to V-FILE.
                end.
            end.
            else
                apply lastkey.
        end.

    if V-FILE <> ? then 
        find _FILE where _FILE._FILE-NAME = V-FILE no-lock.
 
    update V-FIELD with frame main
        editing:
            readkey.
            if keylabel(lastkey) = "?" then do:
                hide frame main.
                {help-br.i 
                    &TABLE=_FIELD 
                    &WHERE="_FIELD._FILE-RECID = recid(_FILE)" 
                    &FIELD=_FIELD-NAME 
                    &FIELD1=_Data-Type
                    &TYPE=char
                    &ASSGN=_FIELD-NAME 
                    &OUT=V-FIELD
                    &INIT="input V-FIELD"
                    &LABEL="label ""Field Name"""
                } 
                disp V-FIELD with frame main.
                view frame main.
            end.
            else
                apply lastkey.
        end.

    find _FIELD 
        where _FIELD._FILE-RECID = recid(_FILE) and
              _FIELD._FIELD-NAME = V-FIELD no-lock.
    hide frame main.

    find first _field-trig of _FIELD no-lock no-error.
 
    display 
         _FIELD._order          colon 8
         _FIELD._field-name     colon 8  label 'FldName'
         _FIELD._label          colon 8
         _FIELD._col-label      colon 8  label 'Col-Lab'
         _FIELD._data-type      colon 8  label 'DataTp'
         _FIELD._decimals                label '    Dec'
                            when _FIELD._decimals ne ?
         _FIELD._extent                  label ' Extent'
         _FIELD._mandatory               label ' Mand'
         _FIELD._fld-case                label '   CaseSens'
         _FIELD._format         colon 8
         _FIELD._view-as        colon 8  label 'ViewAs'
         _FIELD._initial        colon 8  label 'Init'
         _FIELD._help           colon 8
         _FIELD._desc           colon 8  format 'x(69)'
         _FIELD._valexp         colon 8  format 'x(69)'
         _FIELD._valmsg         colon 8  format 'x(69)'
         _FIELD._can-read       colon 8  label 'CanRd'
         _FIELD._can-write      colon 8  label 'CanWr'
       &if entry(1,proversion,".") > "6" &then
         available(_field-trig) colon 8  label 'Trigger'
         'Event:' to 8          when available _field-trig
         _field-trig._event     no-label
                            when available _field-trig
         'Proc:'                when available _field-trig
         _field-trig._proc-name no-label
                            when available _field-trig
       &endif
         skip(1)
         with frame xyz
              1 down side-labels row 4 centered overlay
              title ' DICTIONARY INFORMATION '.
    pause.

    hide frame xyz no-pause.
    clear frame xyz all.
end. /* repeat */ 
hide frame main.