AProcInfo(), EditSource()
These two functions offer programmatic support for the Document View and Task List tools added in VFP 7. AProcInfo() fills an array with a list of the components of a program file and their locations. EditSource() opens any VFP file in the appropriate editing tool. Usage | nCount = APROCINFO( ArrayName, cFileName [, nItemType ] ) |
Parameter | Value | Meaning |
ArrayName | Name | The array in which the list of components is stored. |
cFileName | Character | The file (possibly including a path) for which component information is extracted. |
nItemType | 0 or omitted | List procedures, classes, methods and compiler directives in the array. |
1 | List only classes in the array. | |
2 | List only methods in the array. | |
3 | List only compiler directives in the array. |
Column | Meaning | Applies for nItemType |
1 | Name of item. For methods, the name includes the class name. For classes, includes the "AS" portion of the definition listing the parent class. | 0,2,3 |
Class name. | 1 | |
2 | Line number in the file where the item occurs. | All |
3 | Item type: Define, Directive, Class, Procedure. All procedures, functions, methods and events are classified as "Procedure." | 0,3 |
Parent class name. | 1 | |
4 | Indentation, but always 0. | 0 |
If the class is defined OLEPublic, "OLEPUBLIC". Otherwise, empty. | 1 |
The docs say that, with nItemType = 0 or omitted, the fourth column of the array contains indentation. In our experience, regardless of the indentation of the source file, this column always contains 0. |
Pay attention: The type of the fourth column depends on nItemType. When you pass 0, it's numeric; if you pass 1, it's character. |
Example | * Suppose you have the following in MyCode.PRG: #DEFINE Fred Ethel #DEFINE Lucy Ricky PROCEDURE Irving RETURN DEFINE CLASS Martha AS Form PROC George ENDPROC ENDDEFINE * You can apply AProcInfo(), as follows: ?APROCINFO( aAllStuff, "MyCode.PRG" ) && Returns 5 ?APROCINFO( aClassList, "MyCode.PRG", 1 ) && Returns 1 ?APROCINFO( aMethods, "MyCode.PRG", 2 ) && Returns 1 ?APROCINFO( aDirectives, "MyCode.PRG", 3) && Returns 2 |
Usage | nErrorCode = EDITSOURCE( cShortCutID | cFileName [, nLineNo [, cClassName [, cMethodName ] ] ] ) |
Parameter | Value | Meaning |
cShortCutID | Character | The ID for the shortcut in the task list for the item to be opened. |
cFileName | Character | The file name (including path) of the file to be opened. |
nLineNo | Numeric | The line number within the editing window where the cursor should be positioned. |
cClassName | Character | The name of the class to be opened. |
cMethodName | Character | The name of the method within a class or form that should be displayed in the method editor. |
nErrorCode | 0 | The file was opened successfully. |
Any other number | Something went wrong. See Help for a list of error codes. |
The original release of VFP 7 has one of the strangest bugs we've ever come across. If the third parameter you pass to EditSource() contains a period (say, "x.y"), VFP crashes dead. While we're not sure why you'd pass such a string for the class name, keeling over is pretty rude behavior. Fortunately, it's fixed in Service Pack 1. |
Example | ? EditSource( HOME() + "GenHtml.PRG", 100) ? EditSource( HOME(2) + "TASTRADE\FORMS\BEHINDSC.SCX", 1, ; "Form", "cmdClose.Click" ) |
See Also | #Define, Array Manipulation, Define Class, Modify Class, Modify Command, Modify File, Modify Form, Modify Label, Modify Menu, Modify Procedure, Modify Report |
View Updates
Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.