Extract Function Names in Directory Tree to Sorted File

CodeWright® - API Macro - Royalty Free - 2005.05.09 09:40
Send Comments


Extract Function Names in Directory Tree to Sorted File.

Function Replaced

tlaGetNamesTreeSorted is replaced by tlaNames that has more capabilities:

  • Does not rely on the Routines function.
  • Operates in CodeWright.
  • Operates in CodeWright for .NET.
  • Provides optional sotrting of the output.
  • Provides optional viewing of the output.

tlaNames is documented on this website and is included in tlaTools.

tlaGetNamesTreeSorted is not included in tlaTools.


This function processes every file in the directory tree that matches a user-supplied file definition. This file definition can (and usually will) contain wildcards.

This function runs the Routines( ) function against each file. It detects if the output from Routines( ) contains API macros or functions. It then scans for the macro or function name on each line of the Routines( ) output.

When one is found the macro or function name and its line number are copied to the clipboard and the file name, delimited by tabs, is appended to it.

The contents of the clipboard are written to the file tlaGetNamesTree.xls in the directory set as the root of the tree for processing.

tlaGetNamesTree.xls is then sorted using Sort Version 3.0 from Scott Gartner. (It can be obtained from The sort performed against the file is:

  • Primary key - function name
  • Secondary key - Module name

This file can then be loaded into Microsoft Excel and manipulated.

If you run tlaGetNamesTreeSorted against the root directory of CodeWright 7.0c and you have all of the Microsoft source code installed, it will extract 4,022 function names into the Excel spreadsheet. If you then sort this spreadsheet on Column A you will have an index of every function that is defined in the source code and the file where it resides.

The output file generate will look something like ...

0001: AbortProc             ... \CWDIALOG\print.c    2916
0002: ActivateObjBrowser... ... \CWSTART\browse.c    5651
0003: AddBufferRootNode     ... \CWSTART\outline.c   2599
0004: AddNullString         ... \CWDIALOG\utilmenu.c 8150
0005: AddSymbol             ... \CWSTART\outline.c   3038
0006: AddToolbarControls    ... \CWSTART\cwstart.c   2625
0007: AddWordCompletionWord ... \CWSTART\util.c      5101
0008: AppBasic_add_controlS ... \CWSTART\cwstart.c   3071
4015: writeSection          ... \CWDIALOG\utilmenu.c 4789
4016: writeSection          ... \CWSTART\project.c   1867
4017: xferFileValue         ... \CWDDE\cwdde.c       3042
4018: xferFormatList        ... \CWDDE\cwdde.c       880
4019: xferItemList          ... \CWDDE\cwdde.c       1017
4020: xferSysValue          ... \CWDDE\cwdde.c       1066
4021: xferTopicList         ... \CWDDE\cwdde.c       1122
4022: zeroColumn            ... \CUA\cua.c           1170


tlaGetNamesTreeSorted( );
tlaGetNamesTreeSorted( "*.cs" );
tlaGetNamesTreeSorted( "c:\source", "*.c", "c:\temp\out.xls" );
tlaGetNamesTreeSorted( "", "*.c", "c:\temp\out.xls" );

Input Parameters

Parm Name Code Meaning
1 Root   Prompt for Root specification.
root Root specification to use.
2 Mask   Prompt for selection mask.
mask Selection mask to use.
3 Output   Prompt for output file.
file Output file to use.
4 Parse   Parse function.
macro Pasrse API macros.

Return Codes

Code Message
-1 tlaGetNamesTreeSorted: Function not supported by CodeWright for .NET.
-1 tlaGetNamesTreeSorted: Terminated by request.
number tlaGetNamesTreeSorted: number files found in tree but not processed for 'filename'.
0 tlaGetNamesTreeSorted: No matching files found in tree for for 'filename'.
number tlaGetNamesTreeSorted: number files processed from tree for 'filename'


This function calls tlaError.

This function calls Sort Version 3.0 from Scott Gartner. It can be obtained from


Current version verified under:

  • CodeWright 7.0c
  • CodeWright 7.5.1
  • CodeWright 7.5.2
  • CodeWright for .NET does not support this function

CodeWright for .NET Restriction

This function requires the Compact display capable in CodeWright that is not available in CodeWright for .NET.


There are three primary methods for installing this macro on your system. Method A uses the tlaMDE tool available for purchase from this website. Method B manipulates the macro repository directly. Method C uses the API Macro... tool provided in every copy of CodeWright (but not CodeWright for .NET).

Method A - tlaMDE - CodeWright or CodeWright for .NET

  • Select the Code button on this page.
  • When the second window opens, select all the text in the text box.
  • Issue Ctl-C (copy).
  • Create a new file in CodeWright or CodeWright for .NET.
  • Issue Ctl-V (paste).
  • Issue tlaMDE C (save and compile).

Method B - Copy to Repository - CodeWright or CodeWright for .NET

  • Select the Code button on this page.
  • When the second window opens, select all the text in the text box for a macro.
  • Issue Ctl-C (copy).
  • Load the macro repository "cwright.mac" from your CodeWright or CodeWright for .NET root:
  • issue Ctl-End to go to the end of file.
  • Issue Ctl-V (paste).
  • Close the file and respond yes to the write request.

Method C - API Macro ... - CodeWright Only

  • Select the Code button on this page.
  • When the second window opens, select text from the text box for a macro:
    • Do not select the [API Macro ... header line.
    • Select all other lines in the macro.
  • Issue Ctl-C (copy).
  • Open the CodeWright Tools | API Macros... dialog.
  • Press the New button.
  • Select the Edit box.
  • Issue Ctl-V (paste).
  • Double-click on the function name in the header of the macro.
  • Issue Ctl-C (copy).
  • Select the Name box.
  • Issue Ctl-V (paste).
  • Delete the trailing blank from the name.
  • Select the Save button.
  • Select the Close button.
  • Repeat this process for each macro in the text box.


tlaTools is a Dynamic Link Library that contains most of the API macros on this website in a single easy to install package. The tlaTools DLL can be purchased by selecting the Buy button on this page.

tlaGetNamesTreeSorted is not included as a function in tlaTools.

tlaNames is included as a function in tlaTools.

Copyright © 1993-2005 Thom Little Associates, Ltd. revised 2005.05.09 09:40
One Central Square, Keene, NH 03431-3787 phone 603-357-7567