Jump to content

AutoIt3 Interpreter.


Mat
 Share

Recommended Posts

New version: 1.0.2.8

This is no longer the current version!

Changes this version: [ see full changelog ]

  • Added: Ensures results and prompts are always written on a new line.
  • Added: ConsoleWrite now prints (NB: Compiled Only)
  • Fixed: Leading and trailing whitespace wasn't being removed after stripping comments.
  • Fixed: Unfinished if tests giving bogus results.
  • Fixed: Incorrect error message in variable definition.
  • Added: Handles to the consoles input and output buffers now stored as global values to stop repeated and unnecessary calls to GetStdHandle.
And also 1.0.2.7 which I never posted for:

  • Fixed: If tests now work
  • Fixed: Now strips comments before processing. This turned out to be very important for some of the interpreter logic.
  • Removed: Redundant function definition code. It was test code which can now be found in the beta version (2.0.0.0+)
The svn repositary has been updated, with backlog of a few versions cleared.

Download

Project page

Changelog

Bug tracker

Edited by Mat
Link to comment
Share on other sites

Hey Matt, I did some regression testing in a sober state on both the compiled version of 1.0.2.5 and the uncompiled version. I can reproduce the "Axit" problem in both versions. Here are some steps for reproduction:

- Start the script or compiled program

- Before the line "Au3Int ->" appears, type: Exit

- Press ENTER

- An error will saying that Axit is not a valid keyword.

Again, as I experience more often, the problem seems directly related to typing speed.

I can't test any other versions right now because your project page is returning a HTTP 500.

Edited by Manadar
Link to comment
Share on other sites

Odd... Other google code pages show "Project Hosting is currently READ-ONLY for network maintenance.", but that one is giving me the same error.

Oh wait, try again now, just started working.

As to the error, I don't have a clue as why you are able to type before the prompt is written... That's shouldn't be happening at all (regardless of how fast you type). As a result, I don't know how to fix it. I'll do some searching and see if there is something I'm not doing with the console that I should be. I don't type fast enough unfortunately (My keyboard is still broken, so I use the osk for z x c v and q keys. It's a pain). I still rattle out words at an above average (just) rate though :graduated:

Link to comment
Share on other sites

So this is the same thing as AutoIt, but written in AutoIt?[/sIignore this post.

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

It does feel that way sometimes... When I was writing all the code for variables and arrays with Wraithdu for instance. Execute has certain statements that it doesn't support: local, global, dim, redim and if. As a result I had to write my own interpreter for them.

The good news is that I've figured out how to get loops (and other nested statements) working, once again using includes, so that will be in the next V2 beta. I need to sort out what happens to @error and @extended though, as right now it's not quite there. I'm working on that now though (got a few ideas :x ), so it will be in the next version.

I need some help on what the limit should be (if any) when printing lot's of text. As already shown by Manadar, the system has it's own limit, but you can still print more than enough text to fill the buffer. I'm looking for a way to test if the buffer's been filled after a print, so the a msgbox could give the user some options... There probably is a way, but it's a bit harder than I'd like.

Link to comment
Share on other sites

As to the error, I don't have a clue as why you are able to type before the prompt is written...

I would think that you can start to fill the console buffer as soon as the console is initialized, regardless what your application is doing. So the user starts typing really quick, actually too quick for the console subsystem, and the first letter 'E' is lost. The rest, 'xit<ENTER>' is picked up by the app once it enters the loop where it opens the console for reading and tries to execute 'xit'. Now I'm not sure what the message 'Axit' is about, but I think a simple solution would be to manually flush the console buffer before starting the console reading loop to discard any premature articulations.
Link to comment
Share on other sites

Kk, rewriting the reply for the last time (hopefully).

The problem is to do with the way the console is read. For a long time I've wanted to switch to the Console.au3 functions, but I didn't because it would not work with the standard Autoit console. I would like to know why, and I'll probably ask in the dev section once I know more specifically the problem.

The solution is simple, but means I'm going to have to go back on letting you guys use ConsoleWrite (another strange disparity between use of the winapi and standard autoit consoles). It turns out flushing is what is needed but using ReadConsole is as well.

Please do test :x Any info would be welcome for the Console.au3 project I'm also doing at the moment.

New version: 1.0.2.9 (Current)

Changes this version: [ see full changelog ]

  • Fixed: Random 'A' when typing before the console was ready for input. All text typed before will now be discarded. As a result:

    • Changed: Now uses AllocConsole in both compiled and non-compiled modes.
    • Added: Input buffer is flushed before reading from the console.
    • Changed: Now uses native console functions for reading the console, rather than CreateFile.
  • Noticed: If you invoke Au3Int from the command prompt, then it will make a new console. Whether this is good or bad is up for debate. Whether it can be sorted is up for research.
  • Removed: Redundant calls to some functions such as _Console_SetMode

Download

Project page

Changelog

Bug tracker

Mat

Link to comment
Share on other sites

Hai Mat,

First of all, Axit is indeed fixed. Well done. Now, some bugs:

1. Cannot reassign variables

AutoIt3 Interpreter version: 1.0.2.9
Copyright (c) Matt Diesel (Mat) 2010

Au3Int -> $a = 1
=> 1
Au3Int -> $a = 2
Obscure instruction.
Do you want to re-assign 'a'? y/n y
Do you want to re-assign 'a'? y/n y
Do you want to re-assign 'a'? y/n y
Do you want to re-assign 'a'? y/n y
Do you want to re-assign 'a'? y/n y
Do you want to re-assign 'a'? y/n y
Do you want to re-assign 'a'? y/n y
Do you want to re-assign 'a'? y/n y
Do you want to re-assign 'a'? y/n y
Do you want to re-assign 'a'? y/n y
Do you want to re-assign 'a'? y/n n
Do you want to re-assign 'a'? y/n n
Do you want to re-assign 'a'? y/n n
Do you want to re-assign 'a'? y/n n
Do you want to re-assign 'a'? y/n n
Do you want to re-assign 'a'? y/n n
Do you want to re-assign 'a'? y/n n
Do you want to re-assign 'a'? y/n n

2. Attempting to print long strings still prints nothing. Expected a warning or just the first 1000 chars.

AutoIt3 Interpreter version: 1.0.2.9
Copyright (c) Matt Diesel (Mat) 2010

Au3Int -> "au3int.chm"
=> "au3int.chm"
Au3Int -> FileRead("au3int.chm")
Au3Int -> StringLeft(FileRead("au3int.chm"), 10)
=> "ITSF♥ t . c h
Au3Int -> StringLeft(FileRead("au3int.chm"), 50)
=> "ITSF¿ⁿÑ←µ6▲E╞ƒç;é╫9YT-J≤&±╞▬«τ♦τ╡;∟‼J¼N┬èñ"≈╢x∟²⌂S
Au3Int -> StringLeft(FileRead("au3int.chm"), 100)
=> "ITSF¿ⁿÑ←µ6▲E╞ƒç;é╫9YT-J≤&±╞▬«τ♦τ╡;∟‼J¼N┬èñ"≈╢x∟²⌂S¶îJO╕Qδ1╚7⌡`y├v,÷→⌂≈╠ΩrHδ8
ΣxhZM$╤`☼}û&☼↓î9;}y‼§αj≤
Au3Int ->

I know ... I'm big on "destructive testing". Think that I do it because I think this interpreter is the best thing to happen to AutoIt since coffee.

Edit: Btw this is really cool :x

AutoIt3 Interpreter version: 1.0.2.9
Copyright (c) Matt Diesel (Mat) 2010

Au3Int -> Binary("hi")
=> 0x6869
Au3Int -> Binary(5)
=> 0x05000000
Au3Int -> Binary(0.12)
=> 0xB81E85EB51B8BE3F
Au3Int ->
Edited by Manadar
Link to comment
Share on other sites

  • When did that break? If it's the latest version then I'm going to have a look at that, as I'm sure it was working before. Thanks for reporting it.
  • The system has clearly got a limit of sorts, although it is not documented on msdn. I agree that the interpreter should be checking for this sort of thing. This presents several issues:

    • What should the cap be?
    • Can the cap be changed as a setting?
    • Should there be an override of some kind so that strings over the limit can be printed?
  • It has been an ongoing thing that there is no way for people to clear the buffer other than to type clr or cls into the prompt. I did at one point try to get an item into the console context menu. This almost worked but it wouldn't let me hook the window to get the click on the item. I'm open to any other suggestions as to how one could clear the prompt when it is full.
  • Is there a way to check if a string is readable? Checking if it's printable is possible, but would this be a good indicator of readability?
  • That is pretty nice :x And is pretty much the reason I designed this, to test what something look likes. I reckon a function like StringToAsciiArray would look pretty good for testing. Of course, once I finalise version 2 then you will able use includes. Now that would be awesome.

Thanks for testing... Glad to see that my changes fixed Axit. I still need to find out why though, as it could be important for when I come to the fine details of Console.au3. Which I will keep advertising until it's released no doubt. I can't wait for it to be released, as I really need some more of the functions for the interpreter.

Mat

Edit: And of course one last point... GUIs. At the moment there is nothing stopping you from making them, only they freeze as there is no way to pick up the messages. I don't know if I should just block people making GUI's or possibly find a way to make it work (probably using SetWindowLong and changing the hook for the window to my own basic hook procedure). I'll have to explore that as well. To think that when I started this project I thought it would be nice and simple based on the fact that AutoIt is an interpreted language. How wrong I was.

Edited by Mat
Link to comment
Share on other sites

I'm just going to pretend to be your customer now, am paying you and we're making requirements in a second iteration.

1. Yes, latest version broke this functionality.

2. How does Ruby interpreted handle extremely long strings?

2.1. Seems like a good place to put a cap is when a human will no longer find it worthwhile to read everything. Somewhere around 100k of data. Although, this could be an option - And default to something like 1000 (about one screen worth of information) and will print " -- String cut off".

2.2. I'd definitely say yes. A low default option with the possibility to go higher. If you accidentally print a files content where you wanted to print the files name, you don't want to wait 20 seconds until it has printed everything. However, if you run into issues with the maximum then you should be able to set a max.

2.3 You could override the default limit by setting it to a higher value. Somewhere there should be a hard cap to avoid having printed nothing (or maybe error check after printing).

i.e. I want a cap which you can set by typing a command like: setcap 5000. which will set the new cap to 5000 characters or bytes depending on the type of the variable. Binary -> number of bytes, anything else -> Characters. Maybe there should be a cap on arrays now that I think about it .....

3. I don't know how this works on the inside. But this is definitely something that should be fixed if this is going to see mass consumption. Along with this, I am running into the maximum length for each line of input which is somewhere around 200 characters. If you keep running into limitations of the console window, or the way you interact with it, maybe a GUI is more appropriate. I have no preference here, all I want is output data and for it to read nicely. The console makes it hard to copy stuff.

4. You shouldn't check if a string is readable because it's not relevant. If a program expects an unreadable string from calling a function then he'd want that string to be unreadable. Another thing is if a string contains only unprintable characters, such as NUL. But printing an empty line is fine here. The programmer knows something was printed, so he'll try to print it instead by running it through BInary instead.

I was looking for a project to write some automated tests for. This seems like a good as any project, and it's interesting. I'll keep you posted on how that goes. This is also why I don't look at the source; This test will be black box.

Edited by Manadar
Link to comment
Share on other sites

Ok, lot's to work on, may need an increase in budget here :x

I am now implementing the cut off point, but arrays are a different issue. Right now the function calls itself to print sub array elements, and so determining how long it will be before hand is somewhat difficult (short of going through the same procedure and keeping a count).

As to making a GUI... I'll definitely look at how python do IDLE, as that's how I imagine it should be (not that I like tk windows).

Link to comment
Share on other sites

This is interesting too. I'm still on 1.0.2.6.

Au3Int -> _winapi_setlasterror(0)
=> 1
Au3Int -> _winapi_getlasterror()
=> 6
Au3Int -> _winapi_setlasterror(0)
=> 1
Au3Int -> _winapi_getlasterrormessage()
=> "The handle is invalid.
"
Au3Int ->

Also, at least on Win7 x64, the 'restart' command restarts Au3Int (new process with new PID), but no console window is created.

Link to comment
Share on other sites

This is interesting too. I'm still on 1.0.2.6.

Au3Int -> _winapi_setlasterror(0)
=> 1
Au3Int -> _winapi_getlasterror()
=> 6
Au3Int -> _winapi_setlasterror(0)
=> 1
Au3Int -> _winapi_getlasterrormessage()
=> "The handle is invalid.
"
Au3Int ->

Also, at least on Win7 x64, the 'restart' command restarts Au3Int (new process with new PID), but no console window is created.

That first one means I'm doing something wrong somewhere... I'll see exactly what is causing that.

The second is (if it's what I think it is) is just needing the last parameter for run to be $RUN_CREATE_NEW_CONSOLE or something like that. I need to check when that broke.

Maybe I should save the last error (windows one).

Link to comment
Share on other sites

  • 4 years later...

Usually debugging.

 

I'd say with regards to debugging, this can be useful as a way to test Windows GUI control identifiers/locators for the ControlXyz() functions and WinXyz() functions, for automating the Windows GUI. Similar to what you can do testing element locators with Firebug/FirePath/Firefinding for Selenium, as well as using the browser developer/javascript console to do same for Selenium for those that know how to work with the HTML DOM. With no interpreter shell, you have to write/edit script, run script, to test, which to me is more of a hassle to do to test out what Windows GUI locator will or will not work. Since the AutoIt GUI spy tool and other similar tools only tell you what possible identifiers you can use but don't provide an auto generated locator that will work like (the XPath/CSS locator generator) with FirePath, Firefinder for Firebug/Firefox.

And on another related note, this interpreter could be thought of as an enhancement to the "run a single line of code" feature of AutoIt documented here: https://www.autoitscript.com/autoit3/docs/intro/running.htm

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...