SciTE4AutoHotkey output debugging

Post your working scripts, libraries and tools for AHK v1.1 and older
c4p
Posts: 21
Joined: 18 Jan 2017, 18:38

SciTE4AutoHotkey output debugging

16 Mar 2017, 20:22

Script allows output to SciTE4AutoHotKey console output
Includes lines numbers, elapsed time, and variable contents
Comments, suggestions, and improvements welcome

example output for code below
----
#007: [test] = 50, [a] = 5 (0 ms)
>"E:\AHK\Portable AHK\AutoHotkey\SciTE\..\AutoHotkey.exe" /ErrorStdOut "E:\AHK\Ideas\SciTEOut.ahk"
>Exit code: 0 Time: 0.2267
-----

Code: Select all

#Persistent
#SingleInstance, Force
; Heavy lifting of listlines credited to https://autohotkey.com/board/topic/58110-printing-listlines-into-a-file/#entry365156

test:= 50
a := 5
out("test,a")
return

out(vars, clear = 0,prependtext = "",appendtext = "") { 
ListLines, Off
oSciTE := ComObjActive("SciTE4AHK.Application")
if clear
  oSciTe.Message(0x111,420)
if prependtext
  oSciTE.Output(prependtext . "`n")
global  last
linenum := "#" . GetScriptLines(-1) . ": "
Loop, Parse, vars, CSV
{
  eval = % %A_LoopField%
  out := (out ? out . ", " : "") . "["  . A_LoopField .  "] = " . eval 
}
sincelast := (last ? A_TickCount - last : 0)
last := A_TickCount
oSciTE.Output(linenum . out . " (" . sincelast . " ms)" . "`n")
if appendtext
  oSciTE.Output(appendtext . "`n")
ListLines, On
Return
}

GetScriptLines(num = -1,linecodeboth = 0) {
  ; num: -1 = last line *default), 0 = all, 8 line #8
  ; linecodeboth: 0 = linenum (default), 1 = linecode, 2 = both
ListLines, Off ; prevent this from entering line history
  Section := "lines"
   DetectHiddenWindows, On 
   IfEqual Section,, SetEnv Section, Key 
   HidWin := WinExist(A_ScriptFullPath " - AutoHotkey v") 
   OldPar := DllCall("GetParent", UInt,HidWin) 
   GUI +LastFound 
   DllCall("SetParent", UInt,HidWin, UInt,WinExist("ahk_class Shell_TrayWnd")) 
   WinMenuSelectItem ahk_id %HidWin%,,View, %Section%
   Sleep 0 
   ControlGetText lines, Edit1, ahk_id %HidWin%
   WinHide ahk_id %HidWin% 
   DllCall("SetParent", UInt,HidWin, UInt,OldPar) 
   
if num = 0
  return lines
startpos := 1 , linenum := [], linecode:= []
Loop {
  RegExMatch(lines,"O)(?P<line>\d+):(?P<code>.*)",obj, startpos)
  startpos := obj.Pos["line"] + obj.Len["line"]
  if obj.Value["line"]
  {
      linenum.push(obj.Value["line"])
      ;strip time from code \s\(\d|.\),""
      linecode.push(obj.Value["code"])
  } else {
      break
  }
}
if num = -1
  num := linenum.MaxIndex() ; last line

if linecodeboth = 0
  result := linenum[num]
if linecodeboth = 1
  result := linecode[num]
if linecodeboth = 2
  result := linenum[num] . ":" . linecode[num]
ListLines, On
return result
}
krl
Posts: 9
Joined: 15 Dec 2019, 05:45

Re: SciTE4AutoHotkey output debugging

11 Dec 2022, 02:23

Works fine. Need to change this line, if "Invalid class string" error occurs.

Code: Select all

;~ oSciTE := ComObjActive("SciTE4AHK.Application")
oSciTE := ComObjActive("{D7334085-22FB-416E-B398-B5038A5A0784}").
I prefer using spaces like this:

Code: Select all

out("test, a")
So, this changes were made:

Code: Select all

; Loop, Parse, vars, CSV
vars := StrReplace(vars, ", ", "¢")
Loop, Parse, vars, ¢

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Aqualest and 112 guests