; Assemble a 2-dimensional array containing a list of function names and the files
; that hold them. Search the folders defined in the PATHS array
'Searching for available UDFs'
For Each $PATH in $PATHS
$File = Dir($Path + '\*.*')
While $File <> '' And @ERROR = 0
If Left($File, 1) <> '.'
If Right($File, 4) = '.udf' Or Right($File, 4) = '.kxf' Or $File = $SrcFile
If $PATH = '.' And $File <> $SrcFile ; automatically include everything in '.'
; If the .KXF/.UDF file is in the project folder (.), just include it
$FnFiles[$OP] = $PATH + '\' + $File ; add file to array of included files
$OP = $OP + 1
$ = RedirectOutput($LogFile)
' adding project file ' + $PATH + '\' + $File ?
$ = RedirectOutput('')
EndIf ; PATH = '.'
; open the file, read lines until 'function' is found in a non-comment area
; obtain the function name, and add the function name and file name to the array
If Open(3, $Path + '\' + $File, 2) = 0
$Line = Trim(ReadLine(3))
While @ERROR = 0
; Function definition must be in column 1 after trimming spaces to be considered valid
If InStr($Line, 'Function') = 1
; get rid of the 'function ' and split off the function name
$Fn = Trim(Split(SubStr($Line, 10), '(')[0])
$UDFNames = $UDFNames + $Fn + '(,'
$Functions[$FP,0] = $Fn
$Functions[$FP,1] = $PATH + '\' + $File
$FP = $FP + 1
If $FP Mod 8 = 0 '.' EndIf ; status indicator
EndIf
$Line = Trim(ReadLine(3))
Loop ; while not error
$ = Close(3)
EndIf ; Open
$FF = $FF + 1
EndIf ; .udf or .kxf file
EndIF ; not '.'
$File = Dir() ; get next file
Loop
Next ; $Path
? ' ' $FP ' UDFs located in ' $FF ' files.' ?