Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

OutputDebugString implementation


  • Please log in to reply
51 replies to this topic
Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
The command "OutputDebug, Text" has been added in today's release. Thanks for the suggestion.

nduncan
  • Members
  • 32 posts
  • Last active: Oct 04 2009 08:43 PM
  • Joined: 06 Dec 2005

procyon



Joined: 10 Feb 2005
Posts: 14
Location: Tallinn, Estonia

PostPosted: Sat Feb 12, 2005 4:40 pm Post subject: Reply with quote
I spent some time with AHK source, and compiled my version with OutputDebugString support

I added:
1) to script.h enum
ACT_ODS
2) to globaldata.cpp
{"OutputDebugString", 1, 1, NULL}
3) to script.cpp in Line::Perform
case ACT_ODS:
OutputDebugString(ARG1);
return OK;

Compiled result with test script is available from here


I have a number of scripts, some of which run correctly and others which don't, so I badly need to be able to debug. Neither ListVars nor ListLines give me info that I can interpret, so I have been experimenting with DebugView, (there is a new and very recent version) but I don't get any output.

Chris supports Procyon's code quoted above, but how does a rookie like me make any use of it?

I supported an IDE in a poll, but a tutorial on how to use DebugView with simple examples might take less time.There may be one available but I haven't found it.

Incidentally AutoIt3 (your great rivals!) have what looks like a complete IDE, but the language is definitely inferior as I found out when I tried to write some scripts with it
oldie

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
I use it.

It is pretty simple, inside your code, you specify
OutputDebug, l(%A_LineNumber%): %Text% - file(%A_LineFile%)
with text being a variable that holds the text you want to see.

Now start DbgView

Start your script. If the code reaches the OutputDebug command, you'll see the text in the DbgView window. That's it.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005

Incidentally AutoIt3 have what looks like a complete IDE

Can you please post a link to that IDE?
I see that they have an editor (modified SCITE) but couldn't find an IDE. When it comes to an editor I have the same functionality in PSPad (only code collapse is missing).
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

nduncan
  • Members
  • 32 posts
  • Last active: Oct 04 2009 08:43 PM
  • Joined: 06 Dec 2005
Toralf,

I didn't get an email notification for your last message and my mail seems to be working fine. Is there anything I can do about it?

In any case the AutoIt server seems to be down, so I have mada a stickie to remind me.
oldie

nduncan
  • Members
  • 32 posts
  • Last active: Oct 04 2009 08:43 PM
  • Joined: 06 Dec 2005
Toralf,

First I thought that I had to start DebudView from inside the script. That at least is sorted out.

I have a very simple script (BeepTest.ahk), which I use as its name implies. It used to work, but now only the recently added wav file does. They are not important commands in themselves, but I am stuck as I can't yeyt tell if it is a bug or not.

I attach the script for your perusal
; http://www.autohotkey.com
; Written by <Nigel Duncan> nduncan@cqmail.net
; File name: BeepTest.ahk
#SingleInstance force
; #Persistent ; Comment in or out as required
; #UseHook
; #InstallKeybdHook
; #NoTrayIcon ; Comment in or out as required
; SetTitleMatchMode, 2
; AU WINDOW SPY Hotkeys Run: Ctrl+W Own: Shift+Alt+Tab to freeze
; CONTEXTSENSITIVEHELP  Hotkeys Run: Alt+Win+H Own: Ctrl+2 PREFERRED
; INTELLISENSE  Hotkeys Run: Alt+Win+I Own: , or spacebar LATER USE
; SCRIPTLET LIBRARY Run: Alt+Win+S

SoundPlay, %A_WinDir%\Media\ding.wav, 1
OutputDebug, l(%A_LineNumber%): %ErrorLevel% -
Sleep, 1000
SoundPlay, *-1
OutputDebug, l(%A_LineNumber%): %ErrorLevel% -
Sleep, 1000
SoundPlay, *16
OutputDebug, l(%A_LineNumber%): %ErrorLevel% - 
Sleep, 1000
SoundPlay, *32
OutputDebug, l(%A_LineNumber%): %ErrorLevel% -
Sleep, 1000
SoundPlay, *48
OutputDebug, l(%A_LineNumber%): %ErrorLevel% - 
Sleep, 1000
SoundPlay, *64
OutputDebug, l(%A_LineNumber%): %ErrorLevel% -

Return ; Return to calling script, or Exit

I also have a longish and detailed file on my hit-and-miss attempts to make sense of Debugview's output code, but I don't know hoe to send it without clogging up the forum.

In my view at least the help page on AutoDebug should be greatly expanded.

BTW, with reference to my previous post, my mail is confiremed ok as a test message to myself has just arrived-.

I'll send this now and the text file later, when I find out how.
oldie

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
The script above works on my PC.

Since we have solved your problem with OutputDebug you should post your new questions in a new post if they have nothing to do with the current topic.

In my view at least the help page on AutoDebug should be greatly expanded.

Please suggest a better way. Write a better help page and post it. If it is better I'm sure Chris will use it.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

I didn't get an email notification for your last message and my mail seems to be working fine. Is there anything I can do about it?

Yes, edit your post and check the "Notify me when a reply is posted" checkbox... And maybe change your profile's preferences to make it permanent.

In my view at least the help page on AutoDebug should be greatly expanded.

As toralf pointed out, Chris welcome help improvement suggestions, if he finds them useful. So give a rewording of the parts that confused you, he will look at it.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

nduncan
  • Members
  • 32 posts
  • Last active: Oct 04 2009 08:43 PM
  • Joined: 06 Dec 2005
toralt & Phil.ho

1. The email notification is working today - it must have been a glitch.

2. Autoit3's download page is http://www.autoitscr...3/downloads.php

3. You have to download and install autoit3 first.

4. The IDE is called AutoIt Script Editor.

5. As for the AutoDebug help file I don't know enough to be able to write anything useful. If someone else does it I would certainly post any comments that seemed relevant or where I still had doubts.

6. You don't say anything about getting the text file to you. I don't see any attachment button.
oldie

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
AutoIt Script Editor is, AFAIK, a custom version of SciTE, a simple text editor. I don't know how much they improved it, but to become an IDE, it has to manage projects, allow debugging, list functions in the project, and so on. Otherwise, it is just a glorified text editor.
We can do the same for AHK – I wrote a lexer for Scintilla, ie. for SciTE, although it isn't finished. If some glitches are removed from the language, a lexer for the v.2 would be easier to do...
Right now, it is still a vague project.

Note: you don't have to send a text file, you can just paste it in a public or private message. Unless it is very big, of course. Or ask privately for an e-mail. Or upload it on some site.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

nduncan
  • Members
  • 32 posts
  • Last active: Oct 04 2009 08:43 PM
  • Joined: 06 Dec 2005
Toralf asked me for the URL for the AutoIt Script Editor. It seems to have a lot of things in it, but I'm no expert - it is certainly more than a "Glorified Text Editor", but of course it may not work too well.

As for the text file I don't see the way to send a private message, so I'll just paste it in below. I was trying to avoid clogging up the forum with something of only individual interest. It contains a very detailed description of my attempts (based on Toralf's suggestion) to use DebugView to debug my test script and asks for help as I don't understand the results.

Hence my plea for amplified help on OutputDebug.

Here is the text file. I'll try using the List tag as I´m not sure what it does,DEBUGVIEW OUTPUT FROM FOLLOWING SCRIPT WITH WIN32, KERNEL AND EVENTS ENABLED

; http://www.autohotkey.com
; Written by nduncan@cqmail.net
; File name: BeepTest.ahk
#SingleInstance force
; #Persistent ; Comment in or out as required
; #UseHook
; #InstallKeybdHook
; #NoTrayIcon ; Comment in or out as required
; SetTitleMatchMode, 2
; AU WINDOW SPY Hotkeys Run: Ctrl+W Own: Shift+Alt+Tab to freeze
; CONTEXTSENSITIVEHELP Hotkeyz Run: Alt+Win+H Own: Ctrl+2 PREFERRED
; INTELLISENSE Hotkeyz Run: Alt+Win+I
; SCRIPTLET LIBRARY Run: Alt+Win+S
; DEBUGVIEW W/O LOG Hotkeyz Run: Alt+Win+V
SoundPlay, %A_WinDir%\Media\ding.wav, 1
OutputDebug, l(%A_LineNumber%): %Text% - file(%A_LineFile%)
Sleep, 1000
SoundPlay, *-1
OutputDebug, l(%A_LineNumber%): %Text% - file(%A_LineFile%)
Sleep, 1000
SoundPlay, *16
OutputDebug, l(%A_LineNumber%): %Text% - file(%A_LineFile%)
Sleep, 1000
SoundPlay, *32
OutputDebug, l(%A_LineNumber%): %Text% - file(%A_LineFile%)
Sleep, 1000
SoundPlay, *48
OutputDebug, l(%A_LineNumber%): %Text% - file(%A_LineFile%)
Sleep, 1000
SoundPlay, *64
OutputDebug, l(%A_LineNumber%): %Text% - file(%A_LineFile%)
Return ; Return to calling script, or Exit

THIS TEST FILE WORKED PERFECTLY UNTIL RECENTLY. NOW ONLY THE FIRST LINE (ADDED TO TEST THE SOUND SYSTEM) PRODUCES A SOUND

OUTPUT WITH WIN32, KERNEL AND EVENTS ENABLED

0 [3224] l(18): - file(C:\Documents and Settings\Administrator\Scripts\AHK Other\BeepTest.ahk)
1 [3224] l(21): - file(C:\Documents and Settings\Administrator\Scripts\AHK Other\BeepTest.ahk)
2 [3224] l(24): - file(C:\Documents and Settings\Administrator\Scripts\AHK Other\BeepTest.ahk)
3 [3224] l(27): - file(C:\Documents and Settings\Administrator\Scripts\AHK Other\BeepTest.ahk)
4 [3224] l(30): - file(C:\Documents and Settings\Administrator\Scripts\AHK Other\BeepTest.ahk)
5 [3224] l(33): - file(C:\Documents and Settings\Administrator\Scripts\AHK Other\BeepTest.ahk)

OUTPUT WITH WIN32 DISABLED - NONE
OUTPUT WITH KERNEL DISABLED - AS FIRST EXAMPLE
OUTOUT WITH EVENTS DISABLED - NONE

THEREFORE, AT THIS STAGE, LEAVE ALL THREE ENABLED

DELETE file(%A_LineFile% FROM LAST LINE AS IT DOESN'T PROVIDE USEFUL INFO - AS EXPECTED FILENAME IS NOT SHOWN

REMOVE ALL FOR CLARITY

CHANGE %Text% FOR %Var% - NO VISIBLE CHANGE

RUN WITH LOG FILE

The log contents are given below:

[\\A]
00000000 18:46:00 [3516] l(16): -LESS INFO

ADDING BOTH VARIANTS OF CopyOfVar = %Var%
MsgBox The value in the variable named Var is %Var%.
DO NOT WORK, THEREFORE %Var% cannot be used

SUBSTITUTED %errorlevel% FOR %Var% AND GOT THE FOLLOWING RESULTS

[2856] l(16): 0 -
[2856] l(19): 0 -
[2856] l(22): 0 -
[2856] l(25): 0-
[2856] l(28): 0 -
[2856] l(31): 0 -

WHY IS THE ERRORLEVEL SHOWN AS 0 FOR ALL (THE FIRST WORKS BUT THE OTHERS DON'T).

IN ANY CASE HOW DO I PROGRESS FROM HERE?

I'm quite pleased withe effect of the list tag!
oldie

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Do you have any clue what you are doing?

Sorry, but I guess not. Of cause, %text% doesn't give you any information. Since the var text never has any content. The only reasonable var you could use is errorlevel. And you tried it, and you even see the output, AHK doesn't receive an error.
And I told you that your script works on my system. So it is the problem of your system, not of AHK.
Have you checked your window sound settings? You may have the notifications turned off. Also check all volume settings.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

  • Guests
  • Last active:
  • Joined: --
toralf

Do you have any clue what you are doing?


Obviously not - that's why I'm pleading for more help. It's not meant in any derogatory way, but I soetimes get the impression that AHK is populated mainly by people like yourself that can write code with your eyes shut. That way beginners don't get much of a look-in, and there will always be beginners who need help and encouragement.

However I got as far as Errorlevel under my own steam and Debugview gives an errorlevel of 0 for all five lines, and yet only the first line produces a sound. I put that first line there precisely to check the sound system and the other lines worked perfectly before, so I don't see how it can be my system.

Possibly, since the coded sounds cannot be condidered in any way important, they might have been dropped, but they are still there in the help file. If that is the case, I also understand the effort required to keep documentation up-to-date,

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
No, the documentation is ok, the sounds work on my system. There is something with your system. Could please someone else varify?
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
The script works fine for me.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")