But I'm really not in the mood to finish writing the function below, so, if there is any other alternative out there, please share here!
Code: Select all
Script =
(join`r`n
Test()
yyy()
xxx()
Test() ;__________________________________________________
{
Static x := "#A_ThisFunc"
msgbox, `% x " - function name"
}
yyy() ;__________________________________________________
{
Static x := "#A_ThisFunc"
msgbox, `% x " - function name"
}
xxx() ;__________________________________________________
{
Static x := "#A_ThisFunc"
msgbox, `% x " - function name"
}
)
Temp_Script_File_Name := "#_AHK_Temp_Pre_Edited_Script.ahk"
gui,add, button, gPreRunScript, Pré-Edit and Run Script
gui, add, button, x+5 gShowPreEdScript, show Pre-Edited code
gui, add, edit, xm w800 h600 +HScroll +HwndUserInputControlId, % Script
gui, show
return
ShowPreEdScript: ;___________________________________
ControlGetText, UserScript, , % "ahk_id" UserInputControlId
gui ShowPreEdScript:default
gui, destroy
gui, add, edit, w700 h500 +HScroll +HwndPreEdScriptOut,
ControlSetText , , % Pre_Edit_Script(UserScript), % "ahk_id" PreEdScriptOut
gui, show
return
PreRunScript: ;_________________________________________
ControlGetText, UserScript, , % "ahk_id" UserInputControlId
FileDelete, % Temp_Script_File_Name
FileAppend , % Pre_Edit_Script(UserScript), % Temp_Script_File_Name
run, % Temp_Script_File_Name
return
guiclose: ;_________________________________________
exitapp
Pre_Edit_Script(Script) ;_______________ v1.0 _________________
{
MatchLength := 0
FoundPos := 1
loop
{
FoundPos := RegExMatch(Script, "i)((\r|\n| | )(\S+?)\()|(#A_ThisFunc)", Match, FoundPos + MatchLength)
;\s, Matches any single whitespace character, mainly space, tab, and newline (`r and `n)
;"(\r|\n| | )" in use because "\s" does not work correctly!
;\S, means "any non-whitespace character".
if (FoundPos == "" or FoundPos = 0)
break
else
{
if (Match = "#A_ThisFunc")
{
script := RegExReplace(script, Match, #A_ThisFunc, , 1, FoundPos)
MatchLength := StrLen(#A_ThisFunc)
}
else
{
#A_ThisFunc := Match3
MatchLength := StrLen(Match)
;msgbox, % "'" Match "' - '" Match1 "' - '" Match2 "' - '" Match3 "'"
}
}
}
return, Script
}