is there a way for echo (coordinate row, coordinate column)?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
nnnmmm
Posts: 162
Joined: 26 Aug 2017 06:11

is there a way for echo (coordinate row, coordinate column)?

#1 Post by nnnmmm » 09 Dec 2024 04:16

i need to display about 50 rows of data
is there a way to do this with like some notions below?
like defining
channel A: as 1 to 40th column
channel B: as 41 to 80th column
echo channel A: 111111 or channel A:echo "i was here A:"
similarly
echo channel B: "i was here B:"

or
echo (coordinate row, coordinate col)
then
it would be like
echo (1,1) "i was here at top left"
echo (10,41) "i am here at mid mid now, tell me where i am gonna be, i will be right there"

miskox
Posts: 633
Joined: 28 Jun 2010 03:46

Re: is there a way for echo (coordinate row, coordinate column)?

#2 Post by miskox » 09 Dec 2024 12:19

You have two options:
- use escape sequences
- use space as a filler in your strings

Saso

Aacini
Expert
Posts: 1920
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: is there a way for echo (coordinate row, coordinate column)?

#3 Post by Aacini » 09 Dec 2024 14:14

This seems to me as X-Y problem. If you generate the 50 rows in sequential order, you can store the Channel A: rows in an array, and then show the array elements in the same lines of Channel B: rows:

Code: Select all

@echo off
setlocal EnableDelayedExpansion

rem Generate Channel A: rows and store they in an array
for /L %%i in (1,1,25) do set "ChannelA[%%i]=Channel A #%%i result: !random!"

rem Create filler spaces for Channel A: rows
set "filler40="
for /L %%i in (1,1,40) do set "filler40=!filler40! "

rem Generate Channel B: rows and show they in the same lines of Channel A:
for /L %%i in (1,1,25) do (
   set "left=!ChannelA[%%i]!%filler40%"
   echo !left:~0,40!Channel B #%%i result: !random!
)
Anyway, if you really want to move the cursor to any position in the screen, you can use escape sequences in modern Windows consoles, or use the technique described at Move cursor to *any position* using just ECHO command in any Windows version from XP on.

Antonio

nnnmmm
Posts: 162
Joined: 26 Aug 2017 06:11

Re: is there a way for echo (coordinate row, coordinate column)?

#4 Post by nnnmmm » 09 Dec 2024 22:27

https://mega.nz/file/DQBhAKwC#LQSZgbnLH ... yrdokWOyV8
this link shows the screenshot of the problem i had when a batch ran out of rows

Code: Select all

@echo off
SET PBE1O=BEIGE 1-O.ICO
SET PBE1X=BEIGE 1-X.ICO
SET PBL1O=BLACK 1-O.ICO
SET PBL1X=BLACK 1-X.ICO
SET PB1O=BLUE 1-O.ICO
SET PB1X=BLUE 1-X.ICO
SET PGR1O=GRAY 1-O.ICO
SET PGR1X=GRAY 1-X.ICO
SET PGR2O=GRAY 2-O.ICO
SET PGR2X=GRAY 2-X.ICO
REM ---------------------
SET PO1O=ORANGE 1-O.ICO
SET PO1X=ORANGE 1-X.ICO
SET PO2O=ORANGE 2-O.ICO
SET PO2X=ORANGE 2-X.ICO
SET PPI1O=PINK 1-O.ICO
SET PPI1X=PINK 1-X.ICO
SET PPI2O=PINK 2-O.ICO
SET PPI2X=PINK 2-X.ICO
REM ---------------------
setlocal EnableDelayedExpansion
rem Generate Channel A: rows and store they in an array
FOR /L %%V in (1,1,12) DO (
   IF /I %%V==1  SET PP=%PBE1O%
   IF /I %%V==2  SET PP=%PBE1X%
   IF /I %%V==3  SET PP=
   IF /I %%V==4  SET PP=%PBL1O%
   IF /I %%V==5  SET PP=%PBL1X%
   IF /I %%V==6  SET PP=%PB1O%
   IF /I %%V==7  SET PP=%PB1X%
   IF /I %%V==8  SET PP=
   IF /I %%V==9  SET PP=%PGR1O%
   IF /I %%V==10 SET PP=%PGR1X%
   IF /I %%V==11 SET PP=%PGR2O%
   IF /I %%V==12 SET PP=%PGR2X%
   SET ChannelA[%%V]=!PP!
)

rem Create filler spaces for Channel A: rows
SET "SpaceFiller="
FOR /L %%U in (1,1,40) DO SET "SpaceFiller=!SpaceFiller! "
rem --------------------------------------------------------------
rem Generate Channel B: rows and show they in the same lines of Channel A:
FOR /L %%V in (1,1,12) DO (
   IF /I %%V==1  SET PP=%PO1O%
   IF /I %%V==2  SET PP=%PO1X%
   IF /I %%V==3  SET PP=%PO2O%
   IF /I %%V==4  SET PP=%PO2X%
   IF /I %%V==5  SET PP=
   IF /I %%V==6  SET PP=%PPI1O%
   IF /I %%V==7  SET PP=%PPI1X%
   IF /I %%V==8  SET PP=%PPI2O%
   IF /I %%V==9  SET PP=%PPI2X%
   SET ChannelB[%%V]=!PP!
   SET "left=!ChannelA[%%V]!%SpaceFiller%"
   SET /A VV=%%V
   SET /A CAnum=!VV!
   IF !VV! LEQ 9 SET CAnum= !CAnum!
   SET /A CBnum=!VV! + 12
   IF %%V LEQ 9 (ECHO !CAnum!. !left:~0,40! !CBnum!. !ChannelB[%%V]!) ELSE (ECHO !CAnum!. !left:~0,40!)
)
ECHO.
pause
:END
this batch shows 30% of data to simulate the possibility of using it
i can not get rid of the line numbers 3. 8. 17, i need more thinking for this.
i have to decide whether i use the batch without creating empty lines and putting some colors in them to help identify or not.
coming this much of the batch was already good, and the data sequential order display in this way was good,
thanks for this.

*use escape sequences , i dont know what this is yet, but i will try this
*moving cursor to any position --- time to time i went to and had looked at this from NirCMD maybe over a decade but i didnt see how, i will check the ...any position ..link

nnnmmm
Posts: 162
Joined: 26 Aug 2017 06:11

Re: is there a way for echo (coordinate row, coordinate column)?

#5 Post by nnnmmm » 10 Dec 2024 00:43

@echo off

ECHO 111111111111111
ECHO 111111111111111
ECHO 111111111111111
ECHO 111111111111111
ECHO 111111111111111
ECHO 111111111111111
ECHO 111111111111111
ECHO 111111111111111
ECHO 111111111111111

CALL :SetCursor 1 40
ECHO AAAAAAAAA
CALL :SetCursor 6 40
ECHO BBBBBBBBB

CALL :SetCursor 30 1
pause

GOTO :END
:SetCursor
<nul SET /P "= [%~1;%~2H"
EXIT /B

:END

i got it, it was in the same website that showed how to change the color codes
i searched these words "batch echo cursor position escape"
this is going to be a SO wonderful day
thanks for all.

Post Reply