Page 1 of 3

[Class] Console - Standardized Console GUI with Methods

Posted: 13 Feb 2014, 15:29
by AfterLemon
Class: Console - Standardized Console GUI with Methods
by: tidbit, AfterLemon
Version 1.8 | Tue March 11, 2014
[Downloads][Screenshot]
Thank you for your interest! Good ol' tidbit and I worked on this with ease of use, seamless handling, and robust ability in mind. We hope you like it.
As always, we're both here, and on the IRC channel (irc.freenode.net #ahk & #ahkscript) to help.

Now on to the details:

This class is meant to simplify debugging for scripts from simple text handling, to outputting and logging data & arrays.
There's a lot here, so jump in and test it out using our demo scripts below, or write your own setup and tell us what you think we need to add!

Thanks again!

Without further adieu....

Description

Code: Select all

Name:			[Class] Console
Version:			1.8 (Tue March 11, 2014)
Created:		Tue February 11, 2014
Authors:		AfterLemon tidbit
GitHub:			https://github.com/AfterLemon/Class_Console
AutoHotkey:	http://www.autohotkey.com/board/topic/101881-class-console-standardized-console-gui-with-methods/
AHKScript:		http://ahkscript.org/boards/viewtopic.php?f=6&t=2116&p=14026

Functions Available:
Class_Console		to build the console object - use this in place of Console:=new console()
Desc_Console		to view the description of the class
Methods_Console	to view the documentation for the methods
Documentation
Spoiler
Demos
- removed - Please see the Download link at the top (Github has the demos).

Re: Class: Console - Standardized Console GUI with Methods

Posted: 14 Feb 2014, 10:31
by tidbit
Great release :D I would also like to thank Lexikos as the PrintArray function is based on his ExploreObj() (but pretty much unnoticeable now).

Re: Class: Console - Standardized Console GUI with Methods

Posted: 14 Feb 2014, 22:29
by MasterFocus
Looks promising! I'll definitely keep an eye on this. Thanks guys!

Re: Class: Console - Standardized Console GUI with Methods

Posted: 15 Feb 2014, 11:20
by tidbit
You're welcome :D
small update 1.1
when using console.log(OBJECT or ARRAY), any keys with strings are now quoted.

Code: Select all

{"deer":1,33:[11,{"q":1,"w":2,"e":3,1:4},2],"apple":"car"}
arr[33]
    arr[33,1] = 11
    arr[33,2]
        arr[33,2,1] = 4
        arr[33,2,"e"] = 3
        arr[33,2,"q"] = 1
        arr[33,2,"w"] = 2
    arr[33,2,3] = 2
arr["apple"] = car
arr["deer"] = 1
Edit: I see an issue with this. arr[33,2,3] = 2 should be arr[33,3] = 2

Re: Class: Console - Standardized Console GUI with Methods

Posted: 16 Feb 2014, 12:22
by tidbit
fixed the above bug

Code: Select all

a:= new console("a",32,232,400,452,0)
a.show()
o:={"deer":"animal",33:[11,{"q":1,"w":2,"e":3,1:4},2],"apple":"car"}
a.log(o)
a.log()
o:=[1,2,[11,22,[111,222,333,[1111,2222]],33],3,4]
a.log(o)
return

esc::exitApp
I used this class to debug this class :D

Re: Class: Console - Standardized Console GUI with Methods

Posted: 22 Feb 2014, 14:48
by TLM
excellent work guys!

AfterLemon, just moving this 'feature request' item here (stdout > var),
Its from tidbit's dropbox (verbatim):
Spoiler
The endless API function calls I had to make back in vanilla to return the consoles stdout buffer to a var,
now reduced to a few lines, as I said to tidbit, its almost not fair, but amazing that it can be done this way.

If you could add a method for this it would be greatly appreciated.

Re: Class: Console - Standardized Console GUI with Methods

Posted: 22 Feb 2014, 18:15
by AfterLemon
Minor Update

STDout to the console is now available.

TWO new methods now support STDout:
StdOutFull -- Wait until CMD stdout is finished and append it all to the console
StdOutStream -- Stream the CMD stdout appended to the console

An Example:

Code: Select all

a:=new console("a",100,100,400,435)
a.show()
a.StdOutFull("ipconfig.exe")
Sleep,3000
a.clear()
Sleep,3000
a.StdOutFull()
return
This can also be done manually once the object has been created by either of the 2 methods above:

Code: Select all

objExec:=a.objShell.Exec("ipconfig.exe")
While !objExec.StdOut.AtEndOfStream
	a.append(objExec.StdOut.ReadLine())

Re: Class: Console - Standardized Console GUI with Methods

Posted: 22 Feb 2014, 21:09
by TLM
awesome :D

tidbit and I ( mostly tidbit ;) ) tried to figure out how to get the cmd to exec() without the window.
He ended up using the `shell hook event` approach to hide it, it still flashes but seems to work ok.

Still beats a million dllcalls()

Re: Class: Console - Standardized Console GUI with Methods

Posted: 23 Feb 2014, 10:19
by tidbit
aww man. you guys released it before me! I was going to fix some bugs you made before releasing, afterlemon :P
Mine also has a Break feature. I'll show it to you over irc before merging.
I also added a new function and redid the docs/description page a little.

Re: Class: Console - Standardized Console GUI with Methods

Posted: 24 Feb 2014, 01:27
by hd0202
I think here is a problem in class source lines 9 and 13:
TimeFormat should be FormatTime

Hubert

Re: Class: Console - Standardized Console GUI with Methods

Posted: 24 Feb 2014, 10:20
by tidbit
hd0202:
that is the bug i fixed mentioned above :)
there were also 2 or 3 other bugs related to timestamps. I have fixed those. Just waiting for afterlemon to show his face on irc. If he doesn't today I'll just post my fixes and additions.


edit:
Update to 1.3

3 new functions:
cmd()
cmdWait()
timeSinceLastCall()

Bug fixes:
timestamp issues
issues with displaying arrays properly (st_printarr())

misc:
generated console names (if the name was left blank) now uses A_Now instead of a random number.
updated the docs a bit.

Re: Class: Console - Standardized Console GUI with Methods

Posted: 26 Feb 2014, 16:12
by ahk7
Nice class. But I prefer mine with a splash of color - I'm just messing around with it a bit by replacing the edit control with a listview, this makes it possible to use "line numbers" and color text for certain types of data using https://github.com/AHK-just-me/Class_LV_Colors

You can see very early demo here https://github.com/hi5/Class_Console/tree/dev run Demo_LV1.ahk to see a green "array"

Not sure of LVs are the way to go, a scintilla control might do it OR a simple html control which would allow tables, bullet lists, colors ...

One thing I'd also like to see is a resizable window but haven't worked on that yet.

Re: Class: Console - Standardized Console GUI with Methods

Posted: 26 Feb 2014, 16:36
by AfterLemon
I like the idea of having it handle in a way that looks a little bit nicer, but the sacrifices you're making are too much in my opinion.

Take a look at the overall size of the project. Nearly 600 lines, and many of the methods must still be extended. As well things like Console.Pull() will fail and or cause unreliability due to their slow looping data dump.

LOVE the idea, that's for sure.

Re: [Class] Console - Standardized Console GUI with Methods

Posted: 01 Mar 2014, 14:43
by tidbit
Updated to 1.5! - Major release
-----
A new Command Bar has been added!
The TV parameter/effect has been removed.
many updates and bug fixes.
.Eval() (a simple, not a full featured eval)
many command bar commands.
other stuff.

Woohoo!

Re: [Class] Console - Standardized Console GUI with Methods

Posted: 06 Mar 2014, 18:05
by tidbit
1.7

now uses an html (mshtml) control
line numbers
colors
themeable (html/css)
catch
color
other stuff
bug fixes
more fixes

enjoy!

Re: [Class] Console - Standardized Console GUI with Methods

Posted: 06 Mar 2014, 18:40
by cyruz
Hi guys, thanks for the nice work. Just a request... This class, most probably, will be put in the Lib folder, so it would be nice to have description and documentation inside the class file itself. Of course anyone can do it by himself, so no real need...

Re: [Class] Console - Standardized Console GUI with Methods

Posted: 06 Mar 2014, 19:38
by tidbit
I had that originally, but that adds another ~150 lines.
Until AHK has support for classes in the lib (or does it already? maybe it has a different name structure?), I don't see it being useful. Currently I just copy/paste it at the bottom of my script. since you can't name the file Console.ahk and AHK recognizes it like it does functions.

I guess there is always the use of #include, but that has issues. for some users (like me) simply doing "#include console.ahk" gives an error. I need an absolute path. I find it simpler to just copy/paste instead of fetch the full path every time.

Re: [Class] Console - Standardized Console GUI with Methods

Posted: 06 Mar 2014, 20:23
by joedf
very interesting :)

Re: [Class] Console - Standardized Console GUI with Methods

Posted: 07 Mar 2014, 10:08
by cyruz
tidbit wrote:I had that originally, but that adds another ~150 lines.
Until AHK has support for classes in the lib (or does it already? maybe it has a different name structure?), I don't see it being useful. Currently I just copy/paste it at the bottom of my script. since you can't name the file Console.ahk and AHK recognizes it like it does functions.

I guess there is always the use of #include, but that has issues. for some users (like me) simply doing "#include console.ahk" gives an error. I need an absolute path. I find it simpler to just copy/paste instead of fetch the full path every time.
I'm using the "#Include <Console>" approach, I find it very convenient.

Now that joedf is here and because I didn't dig deeper in the code, may I ask one of you what are the main differences between Console and LibCon?

Re: [Class] Console - Standardized Console GUI with Methods

Posted: 07 Mar 2014, 10:36
by AfterLemon
(Not much experience with LibCon, it fails to start due to VarSetCapacity not implemented)

From a not-so-extensive look-over of LibCon, I see that while it has many of the features you would expect a console to have, it is not necessarily built for debugging.

Class_Console is built with the debugging of issues in mind. .Catch() allows you to monitor execution automatically (this feature is something I've wanted since starting AHK 5 years ago), .Debug() allows you to view the script logs, and to the extent possible, everything is self-contained, as small and efficient as possible, and dedicated to finding and fixing the problems in your other scripts.

I'd like to see this as an #Include simply for the efficiency of fixing any script any time. We'll see what we can do.