Jump to content

Au3Check.exe


tylo
 Share

Recommended Posts

TODO:

- silently ignore any unknown line starting with #.

- obey #include-once

- fix spelling in error messages

- multiple input file support. Maybe not.

- print number of errors and warnings

- modify return codes:

0 - Success

1 - Warnings, but no critical errors

2 - Critical errors that would cause the script to fail

3 - Open file error, or illegal arguments/usage of Au3Check.

:D

blub

Link to comment
Share on other sites

Oh, almost forgot. Since the include paths are stored in the registry at "HKEY_LOCAL_MACHINE\SOFTWARE\HiddenSoft\AutoIt3\Include", you could read it and split it. The code I wrote so the compiler/AutoIt can do that is found in scriptfile.cpp and function AutoIt_ScriptFile::IncludeParse() if you want to have a look at my method.

Does Au3Check automatically assume there is an include directory found at $(InstallDir)\Include if AutoIt is installed and $(ScriptDir)\Include if it's not?

Link to comment
Share on other sites

  • Developers

JdeB, how long before you use Lua to run this on the script first, then if no errors are found, run the compiler/interpreter for AutoIt?  (os.execute() looks nice for this...)

Looked at doing it that way but LUA give this annoying DOS window when you shell a program with os.execute... can't find any other way of doing it with LUA....

Here's what I have that works but give's these cmd windows:

au3.properties:

command.7.*.au3=CheckRun $(FileNameExt)
command.name.7.*.au3=CheckRun
command.subsystem.7.*.au3=3
command.shortcut.7.*.au3=Ctrl+Shift+F5
command.save.before.7.*.au3=1

AutoIt3.Lua:

--++++++++++++++++++++++++++++++++++++++++++++++++++ 
-- Run Syntax check & AutoIt
-- shortcut Ctrl+Shift+F5 Check&Run)
function CheckRun(Script) 
   _ALERT("==>Starting AU3Check for:" .. Script)
   pgm='"' .. props["SciteDefaultHome"] ..'\\au3check\\au3check.exe" ' .. Script .. ' >%temp%\\check.log  2>%temp%\\check2.log'
   rc = os.execute(pgm)
   for line in io.lines(os.getenv('temp') .. "\\check.log") do print(line) end   -- show Header info from AU3CHECK
   for line in io.lines(os.getenv('temp') .. "\\check2.log") do print(line) end  -- show errors from AU3CHECK
   _ALERT("==>AU3Check rc:" .. rc)
   if rc == 0 then
      _ALERT("==>Starting AutoIt3 for:" .. Script)
      pgm='"' .. props["autoit3dir"] .. '\\autoit3.exe" ' .. Script .. ' >%temp%\\AutoIt3.log'
      rc = os.execute(pgm)
      for line in io.lines(os.getenv('temp') .. "\\autoit3.log") do print(line) end  -- show errors from AutoIt3
      _ALERT("==>AutoIt3 rc:" .. rc)
   end
   os.remove (os.getenv('temp') .. '\\check.log')
   os.remove (os.getenv('temp') .. '\\check2.log')
   os.remove (os.getenv('temp') .. '\\autoit3.log')
end
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Au3Check V1.01 - added std include paths, unknown lines with # ignored, changed return codes, and minor fixes.

Thanks for the code, Valik. Here is my modified version of getting the include paths. I then use sprintf(full, "%s\\%s", dir, file). It does not add current ".\Include" dir, as I don't like that:

Au3WinStuff::Au3WinStuff()

{

DWORD dwRes;

HKEY hRegKey;

char szTemp[_MAX_PATH];

char szRegBuffer[65535+2]; // 64 KB + double null

m_pIncludeDirs = new char*[256];

m_nIncludeDirs = 0;

if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\HiddenSoft\\AutoIt3", 0, KEY_READ, &hRegKey) == ERROR_SUCCESS )

{

  // Get the install directory's include path and add it as the first directory to search.

  dwRes = _MAX_PATH;

  if ( RegQueryValueEx(hRegKey, "InstallDir", NULL, NULL, (LPBYTE)szTemp, &dwRes) == ERROR_SUCCESS )

  {

    m_pIncludeDirs[m_nIncludeDirs] = new char[_MAX_PATH];

    sprintf(m_pIncludeDirs[m_nIncludeDirs++], "%s\\Include", szTemp);

  }

  // Look for a key called "Include" which is REG_MULTI_SZ and lists some user-defined include directories

  dwRes = 65535;

  if (RegQueryValueEx(hRegKey, "Include", NULL, NULL, (LPBYTE)szRegBuffer, &dwRes) == ERROR_SUCCESS)

  {

    szRegBuffer[dwRes] = '\0';

    const char* szDir = strtok(szRegBuffer, ";");

    while (szDir)

    {

      m_pIncludeDirs[m_nIncludeDirs] = new char[_MAX_PATH];

      strcpy(m_pIncludeDirs[m_nIncludeDirs++], szDir); // assume len is OK.

      szDir = strtok(NULL, ";");

    }

  }

  RegCloseKey(hRegKey);

}

}

blub

Link to comment
Share on other sites

  • Developers

Uploaded V1.02 - seems pretty good now. :D

Tylo, think i hit a bug... Variables cannot start with a number after the $:

$1Test = "Hallo"

C:\test6.au3(1,1) : ERROR: syntax error (illegal character)
$
^

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Fixed. v1.03.

All seems to be working correct now (at least for the stuff i've tested) ..... Thanks very much for this very useful application ... will save time debugging!! Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

You're welcome. :D It has been very educational for me to build this tool.

I just uploaded 1.04 - only a minor fix, but I think AutoBuilder creates such comments.

Hopefully, the grammar doesn't change much in near future, because I won't have time to update it. When that happens, I'll release the source code. However, function/macros can be user-updated by editing the Au3Check.def file.

blub

Link to comment
Share on other sites

Looking good  :huh2:

It's probably bad style on my part to have "#ce -- blah" style comments :D

I disagree... I think it's useful to be able to name your comment sections like that. When you fold the comments down in an editor like SciTE, if it has a little note like that, you'll note what's inside that block without having to open it up and look. I think that makes it better style since you don't have to waste time unfolding to see it.
Link to comment
Share on other sites

I agree, I think it's freaking brilliant, I've got some scripts I'm writing to replace bats, and I put the bat in a comment block, using #cs -- old bat file to keep it organized...

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

  • Developers

Hopefully, the grammar doesn't change much in near future, because I won't have time to update it. When that happens, I'll release the source code. However, function/macros can be user-updated by editing the Au3Check.def file.

Would gladly help out to keep the Checkercode current....

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

JdeB, found a couple small problems with your lua function. The first problem was that it wouldn't accept file's with a space in their name. Fixing that led to the second problem which required quotes around the entire command being sent to os.execute(). I also changed the parameter passed to the function to be the full-path to the script file (Pre-quoted), just in case the working directory is changed for some reason.

command.7.*.au3=CheckRun "$(FilePath)"
command.name.7.*.au3=CheckRun
command.subsystem.7.*.au3=3
command.shortcut.7.*.au3=Ctrl+Shift+F5
command.save.before.7.*.au3=1

function CheckRun(Script) 
  _ALERT("==>Starting AU3Check for: " .. Script)
  pgm='"' .. props["SciteDefaultHome"] ..'\\au3check\\au3check.exe" ' .. Script .. ' >%temp%\\check.log  2>&1'
  rc = os.execute('"' .. pgm .. '"')
  for line in io.lines(os.getenv('temp') .. "\\check.log") do print(line) end   -- show Header info from AU3CHECK
  _ALERT("==>AU3Check rc:" .. rc)
  if rc == 0 then
     _ALERT("==>Starting AutoIt3 for:" .. Script)
     pgm='"' .. props["autoit3dir"] .. '\\autoit3.exe" /ErrorStdOut ' .. Script .. ' >%temp%\\AutoIt3.log'
     rc = os.execute('"' .. pgm .. '"')
     for line in io.lines(os.getenv('temp') .. "\\autoit3.log") do print(line) end  -- show errors from AutoIt3
     _ALERT("==>AutoIt3 rc:" .. rc)
  end
  os.remove (os.getenv('temp') .. '\\check.log')
  os.remove (os.getenv('temp') .. '\\autoit3.log')
end

Edit: Noticed that you are using 2 temp files for Au3Check when you can just redirect stderr into stdout which is redirected into the file. Made that changed to the posted script.

Edit2: Added /ErrorStdOut to the call to AutoIt3.exe, otherwise, redirecting to a file and reading that back to the output pane is pointless. I added that just in case Au3Check does happen to miss something.

Edited by Valik
Link to comment
Share on other sites

  • Developers

JdeB, found a couple small problems with your lua function.  The first problem was that it wouldn't accept file's with a space in their name.  Fixing that led to the second problem which required quotes around the entire command being sent to os.execute().  I also changed the parameter passed to the function to be the full-path to the script file (Pre-quoted), just in case the working directory is changed for some reason.

Edit: Noticed that you are using 2 temp files for Au3Check when you can just redirect stderr into stdout which is redirected into the file.  Made that changed to the posted script.

Had the fullpath in there in the beginning but couldn't get it to work when it had spaces in it. Where ever i put qoutes/double quotes, it would fail.

How did you solve this because i don't see any quotes around the script path ??

EDIT: ok see what you have done... works nicely....

And i stopped looking because it really don't like the 2 open CMD windows. Have seen they are talking about it on their msgboard to build some Win32 Popen solutions for that..

Didn't know about the 2>&1 statement... tnx....

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

The quotes around the script name are passed in the properties file with the line:

command.7.*.au3=CheckRun "$(FilePath)"

That creates the problem where it still won't run. So in both calls to os.execute(), I've added a double quote to the front and back to quote the entire string going to the shell (The error has to do with how quotes are stripped each time you pass through a command line). That means both calls to os.execute() become this:

rc = os.execute('"' .. pgm .. '"')

This seemed to solve all the problems.

I do agree the black boxes are annoying. I'm going to use this in the hopes that somebody figures out something better and implements it soon to make things smoother. But I just can't pass up the usefulness of this tool so for now, I'm going to live with those stupid boxes, I guess.

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...