Programming helpful tool suggestions
Moderator: DosItHelp
Re: Programming helpful tool suggestions
lol!
I see your point. I guess it would only help basic batch file development.
I see your point. I guess it would only help basic batch file development.
Re: Programming helpful tool suggestions
Samir wrote:Which editor has batch syntax highlighting? I want!
I have Visual Studio 6.0, and downloaded a batch highlighter extension, but i didn't found it anymore.
But this is an highlighter Extension including *.bat:http://visualstudiogallery.msdn.microsoft.com/6706b602-6f10-4fd1-8e14-75840f855569
Hopefully working with the 2010 expresss version:http://www.visualstudio.com/de-de/downloads/download-visual-studio-vs
I haven't tested the above Versions, but it may be usefull.
penpen
Re: Programming helpful tool suggestions
Thank you for the links! I was hoping for a notepad++ extension.penpen wrote:Samir wrote:Which editor has batch syntax highlighting? I want!
I have Visual Studio 6.0, and downloaded a batch highlighter extension, but i didn't found it anymore.
But this is an highlighter Extension including *.bat:http://visualstudiogallery.msdn.microsoft.com/6706b602-6f10-4fd1-8e14-75840f855569
Hopefully working with the 2010 expresss version:http://www.visualstudio.com/de-de/downloads/download-visual-studio-vs
I haven't tested the above Versions, but it may be usefull.
penpen
-
- Posts: 81
- Joined: 19 Nov 2013 00:41
Re: Programming helpful tool suggestions
Samir,
My notepad++ comes with keyword highlighting. Not necessarily syntax highlighting. Some examples it highlights FOR or SET, variables. It doesn't tell you if they're wrong. It is helpful though.
My notepad++ comes with keyword highlighting. Not necessarily syntax highlighting. Some examples it highlights FOR or SET, variables. It doesn't tell you if they're wrong. It is helpful though.
Re: Programming helpful tool suggestions
I've seen that before, and I know notepad++ has extensions, so I was hoping someone built one for batch.julesverne wrote:Samir,
My notepad++ comes with keyword highlighting. Not necessarily syntax highlighting. Some examples it highlights FOR or SET, variables. It doesn't tell you if they're wrong. It is helpful though.
Re: Programming helpful tool suggestions
great to be back on this lively forum. Using one of tool dbenham recommended in one of the post here
http://www.contexteditor.org/
free and works for me
http://www.contexteditor.org/
free and works for me
Re: Programming helpful tool suggestions
Samir wrote:Which editor has batch syntax highlighting? I want!
PsPad was one I've played with, and Notepad++ has syntax highlighting too doesn't it?
I don't use an editor with syntax highlighting myself so I can't suggest one from experience.
Re: Programming helpful tool suggestions
julesverne wrote:Sorta seems there should be a file checker, like a spell checker in word. Highlight possibly missing a variable symbol here or this echo will echo nothing, this variable will be empty. AutoHotKey at least runs a check first (of the whole file) before running, it even points to where the issue is. Just seems odd that no one has created a program like this yet for bat...
When I saw this request at first I thought that the solution was quite hard: it requires to duplicate the Batch file parser programmed into cmd.exe! However, if the parser is already there, is there any way to use it in order to show the errors in a Batch file? We could execute the Batch file and try to identify the displayed errors in some way. Well, to achieve this point we would require:
- Trace the execution of the Batch file line by line; this is achieved deleting the "@echo off" command.
- Differentiate the command-lines displayed by the tracing from the normal output of the program; this is done via a "prompt=id" command with a certain identifier.
- Differentiate error messages sent to Stderr from the rest of the output; this is achieved via this trick.
This way the reviewer program may take a Batch file, slightly modify it in order to perform previous steps, execute it and store the output in a file. Then, review the file and report any errors found besides the lines that produce they. Here it is:
Code: Select all
@echo off
rem LintBat.bat: Detect syntax and run-time errors in a Batch file
rem Antonio Perez Ayala
if "%~1" neq "" goto begin
echo Detect syntax and run-time errors in a Batch file
echo/
echo LintBat.bat batchFile parameters
echo/
echo The first line in the batchFile must be "@echo off" and it must not
echo output lines with "number:" at beginning.
echo/
echo The lines reported as "errors" are the ones sent to Stdout
goto :EOF
:begin
setlocal DisableDelayedExpansion
rem Copy the Batch file replacing first line with "prompt=0:"
(
echo set "@prompt=0:"
for /F "usebackq skip=1 delims=" %%a in (%1) do (
set "line=%%a"
setlocal EnableDelayedExpansion
echo !line!
endlocal
)
) > _batchFile.bat
rem Execute the Batch file and redirect all output to a text file,
rem differentiating command-lines with "0:" prefix
rem and error messages with "#:" (number) prefix
shift
(call _batchFile.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 2>&1 1>&3 | findstr /N "^") > output.txt 2>&1
del _batchFile.bat
rem Process the output: when an error message appear, show it with the last command line
setlocal EnableDelayedExpansion
set nextError=1
for /F "tokens=1* delims=:" %%a in (output.txt) do (
ver > NUL
set /A "id=%%a" 2>NUL
if !errorlevel! equ 0 if !id! leq !nextError! (
if !id! equ 0 (
setlocal DisableDelayedExpansion
for /F "delims=" %%c in ("%%b") do endlocal & set "commandLine=%%c"
) else if !id! equ !nextError! (
echo ERROR #%%a: %%b
echo At line: !commandLine!
echo/
set /A nextError+=1
)
)
)
del output.txt
When I tested this program with several small Batch files it produce the desired output!
However, when I tested larger Batch files I encounter some problems: obviously, the redirections performed in the Batch file interfere with the redirections required to differentiate the error messages, although not in all cases. Ok. I deleted any redirections in the Batch files in order to test the reviewer program...
Then, it seems that when a subroutine is called, the error messages produced in the subroutine are displayed after the subroutine return to the main file!
It is necessary to achieve more tests with this method to identify the problems and try to find solutions to them...
Antonio
-
- Posts: 81
- Joined: 19 Nov 2013 00:41
Re: Programming helpful tool suggestions
WHOA!! Aacini! I'm so psyched at the possibility of this. Not just for me, but for all of us who spend countless hours trying to debug just to find out it was one character off or whatever. However, I say "possibility" because I saw this and threw everything else out the window on Thanksgiving to test. Except.. I must be doing something wrong because it's failing as soon as I double click on it. I also tried throwing a .bat of mine on it and failed instantly as well. What am I doing wrong? I think it would be awesome to have people get involved and test this.
UPDATED: I added a pause before the exit /b and that seemed to help. I drop bat file I'm testing onto your bat file. I've got two files now. a _batchFile.bat file and an output.txt file. Taking time now to understand those.
UPDATED: I added a pause before the exit /b and that seemed to help. I drop bat file I'm testing onto your bat file. I've got two files now. a _batchFile.bat file and an output.txt file. Taking time now to understand those.
Re: Programming helpful tool suggestions
Thank you for the link! This one seems like it will be cool to use.brinda wrote:great to be back on this lively forum. Using one of tool dbenham recommended in one of the post here
http://www.contexteditor.org/
free and works for me
Re: Programming helpful tool suggestions
Very nice! This is still quite helpful since I usually test each 'function' of a batch separately before piecing them together in a larger batch.Aacini wrote:julesverne wrote:Sorta seems there should be a file checker, like a spell checker in word. Highlight possibly missing a variable symbol here or this echo will echo nothing, this variable will be empty. AutoHotKey at least runs a check first (of the whole file) before running, it even points to where the issue is. Just seems odd that no one has created a program like this yet for bat...
When I saw this request at first I thought that the solution was quite hard: it requires to duplicate the Batch file parser programmed into cmd.exe! However, if the parser is already there, is there any way to use it in order to show the errors in a Batch file? We could execute the Batch file and try to identify the displayed errors in some way. Well, to achieve this point we would require:
- Trace the execution of the Batch file line by line; this is achieved deleting the "@echo off" command.
- Differentiate the command-lines displayed by the tracing from the normal output of the program; this is done via a "prompt=id" command with a certain identifier.
- Differentiate error messages sent to Stderr from the rest of the output; this is achieved via this trick.
This way the reviewer program may take a Batch file, slightly modify it in order to perform previous steps, execute it and store the output in a file. Then, review the file and report any errors found besides the lines that produce they. Here it is:Code: Select all
@echo off
rem LintBat.bat: Detect syntax and run-time errors in a Batch file
rem Antonio Perez Ayala
if "%~1" neq "" goto begin
echo Detect syntax and run-time errors in a Batch file
echo/
echo LintBat.bat batchFile parameters
echo/
echo The first line in the batchFile must be "@echo off" and it must not
echo output lines with "number:" at beginning.
echo/
echo The lines reported as "errors" are the ones sent to Stdout
goto :EOF
:begin
setlocal DisableDelayedExpansion
rem Copy the Batch file replacing first line with "prompt=0:"
(
echo set "@prompt=0:"
for /F "usebackq skip=1 delims=" %%a in (%1) do (
set "line=%%a"
setlocal EnableDelayedExpansion
echo !line!
endlocal
)
) > _batchFile.bat
rem Execute the Batch file and redirect all output to a text file,
rem differentiating command-lines with "0:" prefix
rem and error messages with "#:" (number) prefix
shift
(call _batchFile.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 2>&1 1>&3 | findstr /N "^") > output.txt 2>&1
del _batchFile.bat
rem Process the output: when an error message appear, show it with the last command line
setlocal EnableDelayedExpansion
set nextError=1
for /F "tokens=1* delims=:" %%a in (output.txt) do (
ver > NUL
set /A "id=%%a" 2>NUL
if !errorlevel! equ 0 if !id! leq !nextError! (
if !id! equ 0 (
setlocal DisableDelayedExpansion
for /F "delims=" %%c in ("%%b") do endlocal & set "commandLine=%%c"
) else if !id! equ !nextError! (
echo ERROR #%%a: %%b
echo At line: !commandLine!
echo/
set /A nextError+=1
)
)
)
del output.txt
When I tested this program with several small Batch files it produce the desired output!
However, when I tested larger Batch files I encounter some problems: obviously, the redirections performed in the Batch file interfere with the redirections required to differentiate the error messages, although not in all cases. Ok. I deleted any redirections in the Batch files in order to test the reviewer program...
Then, it seems that when a subroutine is called, the error messages produced in the subroutine are displayed after the subroutine return to the main file!
It is necessary to achieve more tests with this method to identify the problems and try to find solutions to them...
Antonio
Re: Programming helpful tool suggestions
Looks like Komodo is only a trial?