;-- TIME_STAMP 2021-06-08 14:21:38 v 0.1 #cs - "DebugFuncCallSC.lua" muss in "SciTEStartup.lua" geladen sein - Anwendung Direkt in die Zeile nach einem Funktionsaufruf wird eingefügt: "_DebugFC_Set(@ScriptLineNumber)" Sollte die Folgezeile eine Fehlerauswertung enthalten, dann in die nächste Zeile einfügen. Das Skript prüft ob in der Zeile ein "@error" zu finden ist, und wertet dann die davor liegende Zeile aus. Nun sind die Informationen für "File" Name der Datei, die die Funktionsdeklaration enthält (Include, aktuelle Datei oder "Native") "Func" Name der aufgerufenen Funktion "Line" Zeile des Funktionsaufrufs gespeichert bis zum nächsten Aufruf von "_DebugFC_Set()". Ausgewertet wird dann mit: "$tDebug = _DebugFC_Get()" "$tDebug" enthält die oben bereits benannten Inhalte in den Feldern .File .Func .Line Bsp.: $result = _EineFunktion('bla', $a) ; Aufruf in Zeile #25, Datei aus UserInclude "_MyUDF.au3" $iErr = @error _DebugFC_Set(@ScriptLineNumber) $tDebug = _DebugFC_Get() ConsoleWrite($tDebug.File & '|' & $tDebug.Func & '(' & $tDebug.Line & ')' & @TAB & ($iErr ? 'FEHLER' : 'OK') & @CRLF) ;================================================================================================================== OUTPUT: _MyUDF.au3 | _EineFunktion() (25) OK #ce Global $g_SciTECmd Func _DebugFC_Set($_lineNumber) _ScI_Dostring("DebugFC:FuncFromLine(_1)", $_lineNumber) EndFunc Func _DebugFC_Get() Local $sRead = FileRead(@TempDir & '\DebugFuncCall.result') Local $aSplit = StringSplit($sRead, @CRLF, 1) If $aSplit[0] < 3 Then Return Local $sFile = StringStripWS($aSplit[1], 2) Local $sFunc = StringStripWS($aSplit[2], 2) Local $sLine = StringStripWS($aSplit[3], 2) Local $iLen1 = StringLen($sFile) Local $iLen2 = StringLen($sFunc) Local $iLen3 = StringLen($sLine) Local $tGet = DllStructCreate( _ 'char File[' & ($iLen1 = 0 ? 1 : $iLen1) & '];' & _ 'char Func[' & ($iLen2 = 0 ? 1 : $iLen2) & '];' & _ 'char Line[' & ($iLen3 = 0 ? 1 : $iLen3) & ']') $tGet.File = $sFile $tGet.Func = $sFunc $tGet.Line = $sLine Return $tGet EndFunc ;=============================================================================== ; Function Name....: _ScI_Dostring ; Description......: Einen Luastring mit/ohne Parameter aufrufen OHNE ein Ergebnis zu erhalten ; : Parameter im Lua-String (max. 10) sind in der Form "_1", "_2", .., "_n" zu benennen. ; Parameter(s).....: $_sLua - der Lua-String ; : $p1 - [optional] Parameter1 für den Lua-String ("_1") ; : ... bis ; : $p10 - [optional] Parameter10 für den Lua-String ("_10") ; Return Value(s)..: keine ; Author(s)........: BugFix ( bugfix@autoit.de ) ;------------------------------------------------------------------------------- ; Bsp.: ; ohne Parameter: ; _ScI_Dostring("print('Hallo Welt!')") ; ; mit Parameter: ; _ScI_Dostring("editor:SetSelection(_1,_2)", 4, 14) ;=============================================================================== Func _ScI_Dostring($_sLuastring, $p1=Null, $p2=Null, $p3=Null, $p4=Null, $p5=Null, $p6=Null, $p7=Null, $p8=Null, $p9=Null, $p10=Null) Local $aParamCall[] = [$p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9,$p10], $index = 0 While $aParamCall[$index] <> Null $_sLuastring = StringRegExpReplace($_sLuastring, '_\d+', $aParamCall[$index], 1) $index += 1 WEnd SendSciTE_Command("extender:dostring do " & $_sLuastring & " end") EndFunc ; by BugFix Func _GetHwndDirectorExtension() Local $hActive = WinGetHandle('[ACTIVE]') Local $PIDActive = WinGetProcess($hActive) Local $aExtension = WinList("DirectorExtension") Local $PIDExt For $i = 1 To $aExtension[0][0] $PIDExt = WinGetProcess($aExtension[$i][1]) If $PIDExt = $PIDActive Then Return $aExtension[$i][1] Next EndFunc ; by Jos Func SendSciTE_Command($_sCmd, $Wait_For_Return_Info=0) Local $WM_COPYDATA = 74 Local $WM_GETTEXT = 0x000D Local $WM_GETTEXTLENGTH = 0x000E224 Local Const $SCI_GETLINE = 2153 Local $Scite_hwnd = _GetHwndDirectorExtension() ; Get SciTE DIrector Handle Local $My_Hwnd = GUICreate("AutoIt3-SciTE interface") ; Create GUI to receive SciTE info Local $My_Dec_Hwnd = Dec(StringTrimLeft($My_Hwnd, 2)) ; Convert my Gui Handle to decimal $_sCmd = ":" & $My_Dec_Hwnd & ":" & $_sCmd ; Add dec my gui handle to commandline to tell SciTE where to send the return info Local $CmdStruct = DllStructCreate('Char[' & StringLen($_sCmd) + 1 & ']') DllStructSetData($CmdStruct, 1, $_sCmd) Local $COPYDATA = DllStructCreate('Ptr;DWord;Ptr') DllStructSetData($COPYDATA, 1, 1) DllStructSetData($COPYDATA, 2, StringLen($_sCmd) + 1) DllStructSetData($COPYDATA, 3, DllStructGetPtr($CmdStruct)) $g_SciTECmd = '' DllCall('User32.dll', 'None', 'SendMessage', 'HWnd', $Scite_hwnd, _ 'Int', $WM_COPYDATA, 'HWnd', $My_Hwnd, _ 'Ptr', DllStructGetPtr($COPYDATA)) GUIDelete($My_Hwnd) If $Wait_For_Return_Info Then Local $n = 0 While $g_SciTECmd = '' Or $n < 10 Sleep(20) $n += 1 WEnd EndIf Return $g_SciTECmd EndFunc ;==>SendSciTE_Command Func MY_WM_COPYDATA($hWnd, $msg, $wParam, $lParam) Local $COPYDATA = DllStructCreate('Ptr;DWord;Ptr', $lParam) Local $SciTECmdLen = DllStructGetData($COPYDATA, 2) Local $CmdStruct = DllStructCreate('Char[' & $SciTECmdLen+1 & ']',DllStructGetData($COPYDATA, 3)) $g_SciTECmd = StringLeft(DllStructGetData($CmdStruct, 1), $SciTECmdLen) EndFunc ;==>MY_WM_COPYDATA