Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

generate list of all methods on a form

Status
Not open for further replies.

vfpgolfer

Programmer
Oct 16, 2004
76
US
Is there a way to generate a list of all methods on a form that have code in them? For documentation purposes.
 

Wasn't this answered on UT today?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Not documented, but this will get you started.

Darrell

Code:
local oChooser
oChooser = createobject("frmChooser")
oChooser.show()
read events

define class frmChooser as form
  docreate = .t.
  autocenter = .t.
  caption = "Enumerate Form methods and events"
  datasession = 2
  width = 800
  height = 300
  name = "A"+sys(2015)
  bEnumDefMethsOnly = .f.

  add object grdForms as grid with ;
    top = 10, ;
    left = 10, ;
    width = this.width - 20, ;
    height = this.height - 102, ;
    deletemark = .f.

  add object chkEnumerateDefinedMethodsOnly as checkbox with ;
    top = this.grdForms.top + this.grdForms.height + 4, ;
    left = 10, ;
    caption = "Enumerate Defined Methods Only", ;
    autosize = .t., ;
    tabstop = .f., ;
    controlsource = "thisform.bEnumDefMethsOnly"

  add object cmdEnumerate as commandbutton with ;
    top = this.chkEnumerateDefinedMethodsOnly.top + this.chkEnumerateDefinedMethodsOnly.height + 6, ;
    left = 10, ;
    caption = "Enumerate", ;
    autosize = .t., ;
    tabstop = .f.

  procedure load
    set safe off
    set cent on
    set talk off
    set escap on
    set excl off
    create cursor FormEnumerations (formkey i, methodname c(32), methodcode m)
    index on formkey tag formkey addi

    create cursor ActiveForms (formname c(32), formcaption c(32), EnumerateForm l, formkey i)

    local oForm, nFormKey, i
    nFormKey = 0

    for each oForm in _screen.forms
      nFormKey = nFormKey + 1
      if oForm.name <> this.name
        insert into activeforms (formname, formcaption, formkey) values (oForm.name, oForm.caption, nFormKey)
      endif
    next
    go top
  endproc

  procedure destroy
    clear events
  endproc

  procedure Enumerate
    zap in FormEnumerations
    select ActiveForms
    go top
    local array aFormMembers[1]
    local i, nMembers, oForm, bWriteIt, cMethodCode
    scan
      if ActiveForms.EnumerateForm
        oForm = _screen.forms(ActiveForms.FormKey)
        nMembers = amembers(aFormMembers,oForm,1)
        for i = 1 to nMembers
          if inlist(aFormMembers[i,2],"Event","Method")
            cMethodCode = allt(oForm.readmethod(aFormMembers[i,1]))
            bWriteIt = !empty(cMethodCode)
            bWriteIt = bWriteIt .or. this.bEnumDefMethsOnly
            if bWriteIt
              insert into FormEnumerations ;
                (formkey, methodname, methodcode) value ;
                (ActiveForms.FormKey, aFormMembers[i,1], cMethodCode)
            endif
          endif
        next
      endif
    endscan
  endproc

  procedure grdForms.init
    this.removeobject("column4")
    this.column3.removeobject("text1")
    this.column3.addobject("check1","checkbox")
    this.column3.sparse = .f.
    this.column3.check1.visible = .t.
    this.column3.check1.caption = ""
  endproc

  procedure cmdEnumerate.click
    thisform.Enumerate()
  endproc
enddefine
 
Thanks for all the suggestions. I also found if you use the documenting wizard on a form you get a file fdxref.dbf with list of all methods etc. I then applied following commands to it to get list in excel.
SELECT distinct procname FROM c:\esiver200402\documents\fdxref.dbf INTO table abc260B
COPY TO c:\excel\abc260B FOR !EMPTY(procname) TYPE csv
COPY TO c:\excel\abc260B FOR !EMPTY(procname) TYPE XLS
 

See if these FAQ would be of help to you:

faq184-4392 - "All methods & Events Code in a Project"
faq184-2948 - "Collection of all methods and Events code in Forms"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top