Set Top and Bottom Margins (DECSTBM)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
miskox
Posts: 630
Joined: 28 Jun 2010 03:46

Set Top and Bottom Margins (DECSTBM)

#1 Post by miskox » 05 Nov 2017 13:43

Hello all!

When I was using VT420 (and VT520) video terminals I used this Escape sequence sometimes because it is useful. It can 'lock' the top and bottom part of the screen - so scrolling is only done in the area between. (works on Windows 10 and on systems that support ANSI ESC codes):

Code: Select all

@echo off

REM see VT420 Programmer Reference Manual
REM Set Top and Bottom Margins (DECSTBM)
REM page 134 (pdf page 156/378)

call :makebinvalue 27 DEL

mode CON: COLS=80 LINES=24

cls

for /L %%f in (1,1,24) do echo Some text %%f

echo %chr27%[4;20;r

dir %systemroot%

echo Press enter key many times...

goto :EOF

:makebinvalue
REM par1=value
REM par2: if value is DEL then variable is defined and tmp file is deleted
md _chrs_>nul 2>nul
set "options=/d compress=off /d reserveperdatablocksize=26"
if %~1 neq 26  (type nul >_chrs_\t.tmp
makecab %options% /d reserveperfoldersize=%~1 _chrs_\t.tmp _chrs_\%~1.chr >nul
type _chrs_\%~1.chr | (
(for /l %%N in (1 1 38) do pause)>nul&findstr "^">_chrs_\t.tmp)
>nul copy /y _chrs_\t.tmp /a _chrs_\%~1.chr /b
del _chrs_\t.tmp
) else (copy /y nul + nul /a _chrs_\26.chr /a >nul)
if "%2"=="DEL" (
 for /F "delims=" %%y in (_chrs_\%1.chr) do set "chr%1=%%y"
 del _chrs_\%1.chr
 rd _chrs_
)
goto :EOF

Saso


(Manuals can still be downloaded www.kockarna.si/vt.zip)

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Set Top and Bottom Margins (DECSTBM)

#2 Post by penpen » 09 Nov 2017 02:23

miskox wrote:

Code: Select all

call :makebinvalue 27 DEL
I just found flaw: In ANSI codepages the value 27 is mapped ESC.

You might want to save the escape value to an environment variable in a short way.

penpen

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

Re: Set Top and Bottom Margins (DECSTBM)

#3 Post by miskox » 09 Nov 2017 08:25

penpen wrote:
miskox wrote:

Code: Select all

call :makebinvalue 27 DEL
I just found flaw: In ANSI codepages the value 27 is mapped ESC.

You might want to save the escape value to an environment variable in a short way.

penpen

Parameter DEL means that the 27.chr file will be deleted and variable 'chr27' will be set. (does not mean that 27 is DEL)

Escape sequence used is <ESC> followed by [.

I use this subprogram to generate different values (as I need them). In this specific case Aacini's way is much better.

Thanks.
Saso

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Set Top and Bottom Margins (DECSTBM)

#4 Post by penpen » 09 Nov 2017 14:16

:oops: Sorry! :oops:
(i read too fast... .)

penpen

Post Reply