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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Method Code 1

Status
Not open for further replies.

DEDMOD

Programmer
Feb 1, 2001
721
US
Is there an easy way to programatically access the code you put in a form method from outside the form? I've decided it would be nice to put a method in my standard form which I can use to place notes in about the form. I can think of a number of work-arounds but if there's an easy way to do it, I could save some time.

What I'm envisioning is a program which gathers the notes from each form in a project or even several projects and produces a document summarizing the data.

Dave Dardinger
 
Dave,
One way is to use the Comment Property that's available on (almost) all the controls. Since you can open a Form - .scx (or Class - .vcx) as a table, it's easy enough to parse out this information. (You can use the Baseclass field to determine which type object you're currently on.) Comments are stored in the Properties memo field. They always start on a new line:
Comment=&quot;<your comment goes here>&quot;

Hint: Since you'll only be &quot;reading&quot; these, add the NOUPDATE clause on your USE statement so you can't corrupt these by mistake.

As far as multiple forms/classes in a project, you can use the Project Object to go through the project. (Or you can just open the Project file - .pjx as a table and SCAN through it to pick off the required files.)

Rick

 
Good points all. I'd already done some more thinking and playing around and decided that writing a program to scan the .scx would be the way to go. Using NOUPDATE and scanning the .pjx file should round things out. I think a lot of people use the comment property for various purposes so I'd just as soon leave it free. But it might be that a property might be better than a method. BTW, just what decides if a property is a memo field? I notice that some properties in the property window let you 'zoom' while others don't. I don't know if this has anything to do with it or not, however.

DED
 
Dave,
I believe all the none default properties are stored in the Properties field of the .SCX. This of course include user created properties. So if you define this property on your &quot;Standard&quot; form, and all forms are based on it, then all you'll need to do is add the documentation you want there.

I just created a Form Property in my form base class and called it Formdoc. Now any form that someone enters any data into this property in design mode, will have an entry in the .SCX (actually .SCT to be technically correct). The line in the Properties Memo field will have a line that starts:
formdoc =
and will have all the information keyed in after this.

Code:
*... big loop through project for forms
  USE (lcnext_file) alias testscx
  SCAN
    IF UPPER(LEFT(BASECLASS,4)) <> &quot;FORM&quot; ;
     OR LEN(ALLTRIM(BASECLASS)) <> 4 && ignore formset
      LOOP
    ENDIF
    STORE 0 TO _MLINE && Reset _MLINE to zero
    FOR l_nLineNo = 1 TO MEMLINES(PROPERTIES)
       l_cLine = MLINE(PROPERTIES, 1, _MLINE)
       IF UPPER(WORDNUM(l_cLine, 1)) = &quot;FORMDOC&quot;
         ? SUBSTR(l_cLine, 10) && strip off &quot;head&quot;
         EXIT && Got this one
       ENDIF
    ENDFOR &&* l_nLineNo = 1 TO MEMLINES(PROPERTIES)
    EXIT && Got the one FORM record in this .SCX
  ENDSCAN

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top