Extract a sorted list of functions
Posted: 04 Aug 2023, 19:14
It is often useful to have a sorted list of AHK functions. This is particularly useful for large libraries. Here is a simple function that will extract a list of functions that conform to the format: Function(parameters) { ... code lines ... } etc. It requires input and output file names (with full paths). It reads the input file, extracts all functions meeting the format noted above, and saves the sorted list of functions to the output file.
Code: Select all
; NAME: ExtractSortedFunctionList.v2.ahk
; DESCRIPTION: Strips functions from ahk program code and save it to a file.
; NOTE: Change FullPath, FileIn, and FileOut then execute
;=============================================================================
#Requires AutoHotkey >=2.0-<2.1
#SingleInstance Force ; Recommended so only one copy is runnnig at a time
SetWorkingDir A_ScriptDir ; Ensures a consistent starting directory.
FullPath := "D:\_AHK2\___SCRIPTS\GDIP\Buliasz_AHKv2-Gdip-master\"
FileIn := "Gdip_All_184.v2.ahk"
FileOut := "Gdip_All_184_SortedFunctionList.v2.txt"
FileInFP := FullPath . FileIn
FileOutFP := FullPath . FileOut
{
ExtractSortedFunctionList(FileInFP,FileOutFP)
ExitApp
}
ExtractSortedFunctionList(FIFP,FOFP)
{
StrIn := FileRead(FIFP)
while ((PosSemi := InStr(StrIn,";")) > 0)
{
PosCR := InStr(StrIn,"`n",0,(PosSemi+1))
StrIn := SubStr(StrIn,1,(PosSemi-1)) . SubStr(StrIn,(PosCR+1))
}
StrIn := StrReplace(StrIn,"`r`n","`n")
StrIn := StrReplace(StrIn,"`n`n","`n")
while ((PosCB := InStr(StrIn,"}")) > 0)
{
PosOB := InStr(StrIn,"{",0,-(StrLen(StrIn) - PosCB+1))
StrIn := SubStr(StrIn,1,(PosOB-1)) . SubStr(StrIn,(PosCB+1))
}
StrIn := StrReplace(StrIn,"`n`n","`n")
StrIn := StrReplace(StrIn,"`n`n","`n")
StrIn := Sort(StrIn)
if(FileExist(FOFP))
{
FileDelete FOFP
}
FileAppend StrIn, FOFP
ExitApp
}
Esc::
{
ExitApp
Return
}