# consolewrite as a debuging option: howto?

## Recommended Posts

Hello,

how to use consolewrite to create debug-help output in -well- any console?

The helpfile states it will send to any "console" except dos box. But what IS a console?

This simple loop is doing nothing:

While 1
Sleep(5000)
ConsoleWrite("my little test line")
WEnd

I cannot find how to tell what a "console" is and how to send the text to THIS console...

Basically what I'm thinking of is a plain output window, topmost attribute, to which I can send status lines instead of popping around with msgboxes.

Propably I miss something very basic?

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

##### Share on other sites

Hello,

how to use consolewrite to create debug-help output in -well- any console?

The helpfile states it will send to any "console" except dos box. But what IS a console?

This simple loop is doing nothing:

While 1
Sleep(5000)
ConsoleWrite("my little test line")
WEnd

I cannot find how to tell what a "console" is and how to send the text to THIS console...

Basically what I'm thinking of is a plain output window, topmost attribute, to which I can send status lines instead of popping around with msgboxes.

Propably I miss something very basic?

Regards, Rudi.

If you use an editor like Scite then when you run the script the lines from consolewrite are displayed in the window at the bottom (which you might need to expand by dragging to see.)

There are other ways to debug a script which might be of interest. I wrote a program called AutoMoIt which requires no changes to your script and allows to to display any global variables while it's running. I also wrote (and am still developing) a debugger. Both of these are in Example Scripts. There is also Klaatu's debugger and stumpii's debugger in example scripts. In my totaly biased opinion, if you only need to see global variables then AutoMonit is the easiest to use, but only seeing global variables is a big restriction. After that is it a question of try it and see.

However, for quick and versatile debugging consolewrite is something I wouldn't want to be without so I recommend you get that working first.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

##### Share on other sites

This is the console write debugger that I wrote and use:

DBP("Version 1.0", "Blah blah blah", @error, 0)

#region Function: Debugger #2:  Displays Console writes about errors with optional Message boxes.
Func DBP($s_ver = "",$s_msg = "", $i_err = 0,$i_flag = 0)
; s_msg is the message displayed, $i_err is the error code ;$i_flag toggles messagebox display.  Easily converts your debug notes into a custom errorhandler
If $s_ver = "" Then$s_ver = "DBP: Error notification"
If $s_msg = "" Then$s_msg = "Undefined message and/or error"
$s_msg = "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " &$s_msg
ConsoleWrite($s_msg & " Error: " &$i_err & @LF)
If $i_flag = 1 Then MsgBox(0x1010,$s_ver, $s_msg & @LF & "Error: " &$i_err)
SetError($i_err) ; returns$i_err as @error
EndFunc   ;==>DBP
#endregion

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

##### Share on other sites

Hello.

Thanks for this example code.

This is the console write debugger that I wrote and use:

DBP("Version 1.0", "Blah blah blah", @error, 0)

#region Function: Debugger #2:  Displays Console writes about errors with optional Message boxes.
Func DBP($s_ver = "",$s_msg = "", $i_err = 0,$i_flag = 0)
; s_msg is the message displayed, $i_err is the error code ;$i_flag toggles messagebox display.  Easily converts your debug notes into a custom errorhandler
If $s_ver = "" Then$s_ver = "DBP: Error notification"
If $s_msg = "" Then$s_msg = "Undefined message and/or error"
$s_msg = "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " &$s_msg
ConsoleWrite($s_msg & " Error: " &$i_err & @LF)
If $i_flag = 1 Then MsgBox(0x1010,$s_ver, $s_msg & @LF & "Error: " &$i_err)
SetError($i_err) ; returns$i_err as @error
EndFunc   ;==>DBP
#endregion
It's concept is like what I have tried, and when I run it, nothing happens. So obviously I miss something important? Where should this consolewrite show up?

What is the destianation this consolewrite will send it's output to?

Thanks, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

##### Share on other sites

For a conclusion in the console use special editors, for example SciTE (download it here )

Edited by Baloven

##### Share on other sites

If you use an editor like Scite then when you run the script the lines from consolewrite are displayed in the window at the bottom (which you might need to expand by dragging to see.)

There are other ways to debug a script which might be of interest. I wrote a program called AutoMoIt

AutoMonIt looks great to watch variables, thanks for sharing.

Well, it doesn't work for my installation:

<----------- error message box --------------->
AutoIt Error

Line 9 (file "c:\full\path\to\file\to\be\monitored.au3")

#include '\Include\dllcallback.au3'

Error: Error opening the file.

The path to my Autoit installation is this one:

c:\programme\autoit3\

and the dllCallBack.au3 is sitting here:

c:\programme\autoit3\include\dllCallBack.au3

This looks like the path of the current autoit3 installation cannot be resolved by automonit v1.07, or did I miss something?

BTW: In the sample files for your automonit I had difficulties to download the NoMadMemory.au3 from the filefront URL given. I found a different one by google that worked fine. Could you drop that one in the forums here as well?

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

##### Share on other sites

Hello.

I cannot follow you here ??

I've got, that SciTE is such an editor, that can act as a console. But what makes an application "console-aware"? And, when there might be more than one application that can act as console, how to tell the consolewrite which one to use?

<confused> Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

##### Share on other sites

.....

<----------- error message box --------------->
.......
#include '\Include\dllcallback.au3'
......

......

#include <dllcallback.au3>

see the help on #include in <Program Files Dir>\AutoIt3\AutoIt.chm

## Create an account

Register a new account