Extract and Use System Output (Batch) -


i write batch file allows quicker assembling of multiple assembly files using a86 assembler , view result. there 2 cases, when there assembly error , when there no error.

sample assembler input:

a86 file1.asm file2.asm file3.asm file4.asm 

case 1: error. supposing there error in file3.asm, system output on line 4:

error messages inserted file3.asm 

case 2: no error. system output on line 4:

object: file1.bin 

in case 1, open file generated error using notepad++, using command notepad++ filename.asm.

in case 2, open generated object in hex editor using command hxd filename.bin.

what can done extract error/success file name system output?

sorry, i'm not familiar a86, have idea or two. if a86 returns 0 on success, non-zero on fail, way:

@echo off setlocal enabledelayedexpansion  if defined programfiles(x86) (set "pf=%programfiles(x86)%") else set "pf=%programfiles%"  :: path notepad++ set "npp=%pf%\notepad++\notepad++.exe"  :: path hxd (fix this, please) set "hxd=%pf%\hxd\hxd.exe"  set idx=1  /f "tokens=1-5*" %%a in (     'a86 file1.asm file2.asm file3.asm file4.asm 2^>^&1' ) (     if !idx! equ 4 (         rem if %errorlevel% non-zero (is 1 or higher)         if errrorlevel 1 (             start "" "%npp%" %%e         ) else (             start "" "%hxd%" %%b         )     )     echo(%%a %%b %%c %%d %%e %%f     set /a "idx+=1" ) 

if errorlevel returned a86 not reliable indicator, change if errorlevel 1 if "%%j"==""

you didn't mention whether error output of a86 sent via stderr or stdout, redirected stderr stdout in for loop 2^>^&1. have no clue whether it's needed or not, shouldn't hurt if not.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -