Append/over-write screen text WITHOUT advancing a line
Moderator: DosItHelp
Append/over-write screen text WITHOUT advancing a line
Is there a Control code or some mechanism that is the opposite to a Line Feed ?
I have a script which tests for the existence of several hundred items (files and registry keys),
and for each item it displays one line showing its state after processing.
This occupies many screens of a DOS window.
Most of the target items are normally "ABSENT" and of no interest
I have greatly reduced the height of the display by excluding "ABSENT" items from the display.
This results in a list of items that have been found and processed so far,
and long "coffee break" intervals in which nothing seems to happen as a vast number of items are found to be "ABSENT".
Instinctively after several decades using computers I think of "nothing happening" as a dead computer needing a reboot.
I would like to display the ABSENT item and NOT advance to the next line.
I want the "ABSENT" display line to be re-used without advancing.
I am using CMD.EXE in Windows XP Home edition with SP3.
Alan
I have a script which tests for the existence of several hundred items (files and registry keys),
and for each item it displays one line showing its state after processing.
This occupies many screens of a DOS window.
Most of the target items are normally "ABSENT" and of no interest
I have greatly reduced the height of the display by excluding "ABSENT" items from the display.
This results in a list of items that have been found and processed so far,
and long "coffee break" intervals in which nothing seems to happen as a vast number of items are found to be "ABSENT".
Instinctively after several decades using computers I think of "nothing happening" as a dead computer needing a reboot.
I would like to display the ABSENT item and NOT advance to the next line.
I want the "ABSENT" display line to be re-used without advancing.
I am using CMD.EXE in Windows XP Home edition with SP3.
Alan
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Here's an example that you could adapt that will basically record the output and use a CLS to clear the screen and re-create it each time (I called it the "header"). So you could add an echo that says "still processing -- be patient" at the end each time an ABSENT is found, until you're finally finished:
pingtest.cmd
There's also a code on here somewhere that is part of a "wait" script which will manipulate the current line over and over again. That might be useful.
pingtest.cmd
Code: Select all
@echo off
setlocal enabledelayedexpansion
set array=-1
ping -n 1 -w 1000 %1|find /i "ttl=">nul
if errorlevel 1 goto down
:up
set /a array+=1
set header%array%=%date% %time% %1 Ping is up.
:uploop
cls
for /l %%a in (0,1,%array%) do echo !header%%a!
echo.
ping -n 1 -w 1000 %1|find /i "ttl="
if errorlevel 1 ping -n 1 -w 1000 %1|find /i "ttl="
if errorlevel 1 goto down
ping -n 3 -w 800 127.0.0.1 >nul 2>&1
goto uploop
:down
set /a array+=1
set header%array%=%date% %time% %1 Ping is down.
:downloop
cls
for /l %%a in (0,1,%array%) do echo !header%%a!
echo.
ping -n 1 -w 1000 %1|find /i "ttl="
if not errorlevel 1 goto up
ping -n 3 -w 800 127.0.0.1 >nul 2>&1
goto downloop
:eof
Thanks, but I would like something much shorter and faster.
Incidentally, clearing the screen and then re-writing before appending each of item of status, at 1 second intervals for each of 400 items, is not something I would want to watch on my desk ! !
Last week I had "final code".
When I deleted an item I redirected the console and error streams into 2 temporary files, and appended a single line status report to both the screen and a log file. I evaluated the errors and responses in the temp files and anything unexpected was also appended to the log file.
I found that the log file had a 0.5% chance of not getting everything, I think that after 1 second of processing an item the batch script then appended three items to the log file at less than 1 mSec intervals - not quite long enough for the log-file to be read and then re-written with an extra line of text, especially after the log file reached about 400 lines * 120 characters per line
Everything works 100% now I have given up the log file, and capture everything to screen.
I am afraid that storing all the desired output in an array in memory will require extra care and debugging to ensure correct indexing into the array, after which I may stumble into another "gotcha".
Regards
Alan
Incidentally, clearing the screen and then re-writing before appending each of item of status, at 1 second intervals for each of 400 items, is not something I would want to watch on my desk ! !
Last week I had "final code".
When I deleted an item I redirected the console and error streams into 2 temporary files, and appended a single line status report to both the screen and a log file. I evaluated the errors and responses in the temp files and anything unexpected was also appended to the log file.
I found that the log file had a 0.5% chance of not getting everything, I think that after 1 second of processing an item the batch script then appended three items to the log file at less than 1 mSec intervals - not quite long enough for the log-file to be read and then re-written with an extra line of text, especially after the log file reached about 400 lines * 120 characters per line
Everything works 100% now I have given up the log file, and capture everything to screen.
I am afraid that storing all the desired output in an array in memory will require extra care and debugging to ensure correct indexing into the array, after which I may stumble into another "gotcha".
Regards
Alan
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
You don't have to have a 1 second delay. You also don't have to update the screen for every item -- only when a non-absent item is found. I just posted my code that I already use -- you don't need any of the PING portions -- just the HEADER portions. Let's see if I can pseudo-code it quickly:
If it takes too much processing for the cls and screen updates, then:
Code: Select all
setlocal enabledelayedexpansion
set idx=0
set absent=0
for %%a in (all the stuff you're checking) do call :process %%a
cls
echo Final statistics:
for /l %%a in (1,1,%idx%) do echo !header%%a!
echo Number of ABSENT items: %absent%
goto :eof
:process
if not exist %%a (
set /a absent+=1
cls
for /l %%a in (1,1,%idx%) do echo !header%%a!
echo Number of ABSENT items: !absent!
goto :eof
)
set /a idx+=1
set header%idx%=Whatever the output that you want for a non-ABSENT item
cls
for /l %%a in (1,1,%idx%) do echo !header%%a!
echo Number of ABSENT items: %absent%
goto :eof
If it takes too much processing for the cls and screen updates, then:
Code: Select all
setlocal enabledelayedexpansion
set idx=0
set absent=0
for %%a in (all the stuff you're checking) do call :process %%a
cls
echo Final statistics:
for /l %%a in (1,1,%idx%) do echo !header%%a!
echo Number of ABSENT items: %absent%
goto :eof
:process
if not exist %%a (
set /a absent+=1
goto :eof
)
set /a idx+=1
set header%idx%=Whatever the output that you want for a non-ABSENT item
cls
for /l %%a in (1,1,%idx%) do echo !header%%a!
echo Still processing -- please be patient!
goto :eof
Thanks, but I needed something very simple.
I was not concerned about the "ping" delays.
The 1 second per item was the time taken for REG.EXE to report upon and delete the designated key - it seems to take longer looking for a key that is not present than it does to find and delete a key that is present ! !
My big concern was the epileptic fit inducing properties of clearing the screen and then repopulating it with the last few hundred lines plus the next result.
The other factor is that I have implemented full error checking and reporting upon :-
Changing Current Directory to a designated Path;
Deleting Designated Files on that path;
Deleting Designated Folders on that path;
Deleting Designated registry Keys.
I found %ERRORLEVEL% to be erratic and primitive, especially when using REG.EXE. It gives no clue upon any cause of failure.
Instead I have to capture and evaluate the console stream and error stream from every command, and anything unusual is reported.
There are more than a dozen points in the code where a report is issued.
One dozen points where reports were issued to a log file,
Windows had a 0.5% rate of omission so I altered code to report on screen.
I do not want to revisit bad memories in my mind - especially since I could encounter further problems intrinsic to Windows and its use of RAM memory.
Incidentally, the "random" 0.5% error rate became an absolute predictable 10% rate, i.e. the log file always skipped the tenth report - it captured 9 and then it missed the next - nothing random at all.
I got this monstrous error when I moved the log file from C:\ to V:\
This changed its location on the same physical drive so the head had 30 times as far to seek and travel from the boot sectors edge. (C:\ = NTFS, 15 GB with 10 GB free space, V:\ = FAT32, 45 GB and on the inner edge of a 160 GB drive)
The problem could be position on disc, or partition format,
but as with all things in Windows I prefer to think "DRAGONS BE HERE - KEEP OUT".
I am so close to completion, and I do not want to stumble over more Windows anomalies.
MY SOLUTION :-
Not quite what I wanted, but I am happy to settle for :-
Those two lines replace SET /A "NDY2+=1" which increments an ABSENT counter,
and now the screen text toggles between "Light Aqua" and "Light Yellow" every time another item is found to be ABSENT.
I find this an acceptable indication that the computer is still working as it ploughs through a hundred ABSENT items which are suppressed from the screen.
Regards
Alan
I was not concerned about the "ping" delays.
The 1 second per item was the time taken for REG.EXE to report upon and delete the designated key - it seems to take longer looking for a key that is not present than it does to find and delete a key that is present ! !
My big concern was the epileptic fit inducing properties of clearing the screen and then repopulating it with the last few hundred lines plus the next result.
The other factor is that I have implemented full error checking and reporting upon :-
Changing Current Directory to a designated Path;
Deleting Designated Files on that path;
Deleting Designated Folders on that path;
Deleting Designated registry Keys.
I found %ERRORLEVEL% to be erratic and primitive, especially when using REG.EXE. It gives no clue upon any cause of failure.
Instead I have to capture and evaluate the console stream and error stream from every command, and anything unusual is reported.
There are more than a dozen points in the code where a report is issued.
One dozen points where reports were issued to a log file,
Windows had a 0.5% rate of omission so I altered code to report on screen.
I do not want to revisit bad memories in my mind - especially since I could encounter further problems intrinsic to Windows and its use of RAM memory.
Incidentally, the "random" 0.5% error rate became an absolute predictable 10% rate, i.e. the log file always skipped the tenth report - it captured 9 and then it missed the next - nothing random at all.
I got this monstrous error when I moved the log file from C:\ to V:\
This changed its location on the same physical drive so the head had 30 times as far to seek and travel from the boot sectors edge. (C:\ = NTFS, 15 GB with 10 GB free space, V:\ = FAT32, 45 GB and on the inner edge of a 160 GB drive)
The problem could be position on disc, or partition format,
but as with all things in Windows I prefer to think "DRAGONS BE HERE - KEEP OUT".
I am so close to completion, and I do not want to stumble over more Windows anomalies.
MY SOLUTION :-
Not quite what I wanted, but I am happy to settle for :-
Code: Select all
SET /A "NDY2+=1, WB=NDY2&1"
IF %WB%==0 (COLOR 0E) ELSE COLOR 0B
Those two lines replace SET /A "NDY2+=1" which increments an ABSENT counter,
and now the screen text toggles between "Light Aqua" and "Light Yellow" every time another item is found to be ABSENT.
I find this an acceptable indication that the computer is still working as it ploughs through a hundred ABSENT items which are suppressed from the screen.
Regards
Alan
Re: Append/over-write screen text WITHOUT advancing a line
alan_b wrote:I would like to display the ABSENT item and NOT advance to the next line.
I want the "ABSENT" display line to be re-used without advancing.
Watch this topic: http://forum.script-coding.info/viewtopic.php?id=2945 (Russian)
Googlenglish: http://translate.google.com/translate?hl=en&sl=ru&u=http://forum.script-coding.info/viewtopic.php%3Fid%3D2945 (Careful! Not properly formatted code)
If you only need to append, then use the "echo" substitute
Code: Select all
@echo off
chdir /d "%~dp0"
set "scr=%~dp0\_cho.scr"
echo N _CHO.COM> "%scr%"
echo E 0100 BB 80 00 43 80 3F 0D 75 FA C6 07 24 B4 09 BA 82>> "%scr%"
echo E 0110 00 39 DA 7F 02 CD 21 B4 4C CD 21>> "%scr%"
for %%s in (RCX 001B W Q) do echo %%s>> "%scr%"
debug< "%scr%" >nul
del "%scr%" /q
_cho.com %date%
_cho.com . test first word
_cho.com . test second word.
pause >nul
Re:
!k wrote:If you only need to append, then use the "echo" substitute
debug< "%scr%" >nul
I remember "debug" well.
I used it on a Compaq Luggable PC (heavy suitcase) with DOS 3.32.
One thing I was never brave enough for was to GO to the magic address to format the hard drive.
I had a 3 inch stack of 132 column wide print-out that listed all the magic numbers for everything.
I assumed those numbers are now a bit out of date.
QUESTION - Have the Bios numbers been frozen since DOS 3.32 ?
I remember a forum query where a Windows 98 script failed in Windows NT because CHOICE was no longer supported, so some-one offered a debug hexadecimal machine code script to create a CHOICE.COM, but then an expert pointed it it was not compatible with the more recent computers. How can I determine if a debug script is compatible with my PC - do I just run it and look for a BSOD ! ! !
I am surprised to find that Windows XP still includes Debug.exe, and its companion EDLIN.EXE.
Thank you for your previous post, and for the warning about the format errors in the translation.
This is what I am now using to give the latest count of absent items and avoid the Line Feed :-
Code: Select all
<NUL SET /P Z= ABSENT %NDY2%
Regards
Alan
Re: Re:
debug< "%scr%" >nul
Do not worry. This code works fine on XP SP3.
If you are still afraid debug, then decodes it UUE encoded text and get ready 27-byte file
Code: Select all
begin 644 _CHO.COM
;NX``0X`_#77ZQ@<DM`FZ@@`YVG\"S2&T3,TA
`
end
sum -r/size 29176/27