Jim Hall | 6 Aug 18:36
Favicon

(FWD) Suggestion for FreeDOS debugging

Bryan emailed me a few weeks back to say that he was working with 
FreeDOS on a side-project at his work, and he hoped to send some FreeDOS 
improvements/suggestions related to that.  He's moved to a new area, so 
he won't be able to continue his FreeDOS work.

However, he did send in this interesting .bat trick that he has used 
successfully in the past ... maybe others will find it interesting and 
useful.  Also, Bryan makes a request for a new feature when parsing a 
.bat file.

I thought the FreeCOM list was the most appropriate place to fwd Bryan's 
email:

Bryan Nahrwold wrote:
> Jim:
>  
> I have recently moved to a group that uses imaging and focuses on 
> Windows and Linux, so I will have less occasion to use FreeDos.  
> However, I am still interested in your project.  I feel that there is a 
> long life for DOS as an Automation tool.
>  
> I have one suggestion that I think would greatly improve FreeDOS's debug 
> capabilities.  Of course, I am aware of the command /y /c filename 
> option, but this can be tedious to traverse.
>  
> In my batch files, I use the following construct
>  
> At the top of each batch file:
>  
>> SET TEMP_BAT=CURR_BAT
>> SET CURR_BAT=<name of batch file>
>> 
>> IF "%TRACE%"==""        SET TRACE=FALSE
>> IF "%TRACE%"=="HEADER"  SET DEBUG=FALSE
>> IF "%TRACE%"=="INTO"    SET DEBUG=TRUE
>> IF "%TRACE%"=="FALSE"   SET DEBUG=FALSE
>>  
>> IF "%TRACE%"=="HEADER" ECHO executing %CURR_BAT%...
>> IF "%TRACE%"=="HEADER" PAUSE
 >
> Then at each label, I set something like this:
>  
>> :LABEL1
>> SET LABEL=LABEL1
>> IF "%DEBUG%"=="TRUE" ECHO %LABEL% Label in %CURR_BAT%...
>> IF "%DEBUG%"=="TRUE" PAUSE
 >
> At the end of the batch file, I have:
>  
>> :END
>> SET LABEL=END
>> IF "%DEBUG%"=="TRUE" ECHO %LABEL% Label in %CURR_BAT%...
>> IF "%DEBUG%"=="TRUE" PAUSE
>> SET CURR_BAT=TEMP_BAT
>> SET TEMP_BAT=
>  
> By doing this, I can set TRACE=FALSE and process normally.
> I can set TRACE=HEADER and only pause at the beginning of each batch file
> I can set TRACE=INTO and stop on each label, but not on each line.
>  
> With this process, I add labels to critical areas of the batch file that 
> are not even involved in branching and add statements such as the 
> following to determine how environment variables were set at this point 
> in time.
>  
>> :LABEL2
>> SET LABEL=LABEL2
>> IF "%DEBUG%"=="TRUE" ECHO %LABEL% Label in %CURR_BAT%...
>> IF "%DEBUG%"=="TRUE" ECHO ENV_VAR1:   %ENV_VAR1%
>> IF "%DEBUG%"=="TRUE" ECHO ENV_VAR2:   %ENV_VAR2%
>> IF "%DEBUG%"=="TRUE" PAUSE
>
> Of course, this is only as effective as my ability to type these 
> commands properly.  My debug code can go awry with the
> simplest typo.
>  
> What I'd like to see in FreeDOS is a small amount of code added to each 
> pass through the execution of a line of batch code based on some 
> command-line options or some way of setting something like:
>  
> /T:NP   - Display name of Batch file with no pause (when a batch file is 
> executed)
> /T:P    -  Display name of Batch file and pause (when a batch file is 
> executed)
> /T:LP  - Display current label with no pause (when a label is encountered)
> /T:LP  - Display current label and pause (when a label is encountered)
>  
> My desire is to be able to pause the code at the top of each batch file 
> and display the batch file name, with or without a pause.  (Really, I 
> would always pause in this mode.  I just add the nopause for unforseen 
> needs).  I would also like to be able to set a flag that steps through 
> each label and displays the name, without stopping on every line of 
> code.  These are very helpful in debugging, when I have typed them 
> correctly.
>  
> What would really be great then, but probably not doable, would be some 
> command to dump the current environment variables at that point in time, 
> if the right key were pressed.
>  
> TO me, the virtually non-existent nature of debugging tools is the 
> greatest shortcoming of DOS.  If you have large batch files (and I have 
> many that are 500 to 2500 lines long), this is the single greatest 
> impediment to using DOS effectively.
>  
> I know you try to keep compatibility with MS-DOS, but it seems like it 
> would not take much to add this display of label functionality.
>  
> Think about it, and again, thanks for this great contribution to the DOS 
> community.
>  
> Bryan Nahrwold
> Quality Assurance Engineer

--

-- 
_____________________________________________________________________________
This email message has been automatically encrypted using ROT-26.
NOTE: I WILL BE AWAY FROM EMAIL (ON VACATION) AUG 6-24.

-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com

Gmane