Another "MODE" trick demo
Posted: 05 Sep 2014 10:35
Hi, I have this code for demo the "MODE" trick.
This is old code. If anyone needs...
There is no antiflicker but in the forum there'are suggestion for antiflicker if necessary.
And i think that is necessary to "FLUSH" the input buffer. See in the forum the discussion of "arrow keys"
einstein1969
This is old code. If anyone needs...
There is no antiflicker but in the forum there'are suggestion for antiflicker if necessary.
And i think that is necessary to "FLUSH" the input buffer. See in the forum the discussion of "arrow keys"
Code: Select all
@echo off & setlocal EnableDelayedExpansion & Goto :Init_system
:Main
cls & mode %cols%,%lines%
echo(&Echo Center the dos command windows and&pause
call :wait 1000
cls & mode 15,20 & color 08
set /a tmp_cols=cols, tmp_lines=lines, Cols=15, lines=20, pos=0
For %%c in (4 c e a 2 1 5 8 7 f 7 8 8 7 f b 3 9 1) do (
call :blinking_line !pos! %%c %cols%
set /a pos+=1
)
set cols=%tmp_cols%
mode %cols%,%lines%
call :wait 1000
set /a lines=tmp_lines, pos+=23
mode %cols%,%lines%
call :wait 1000
rem avvio il processo che aspetta un tasto
start "" /B xcopy /w "%~f0" "%~f0" >>"%temp%\wait.tmp" 2>nul
for /L %%n in (1,1,23) do (
call :wait 8
set /a pos-=1
call :press !pos! %%n
)
set /a pos-=1, cle=1
:repeat
(
title !time!
call :press !pos! 13
if !pos! geq 12 (
if !pos! gtr 12 set /a pos-=1
set cl=1
For %%c in (1 9 3 b f 7 8) do (
if !cl! equ !cle! call :ColorText_bg_BS %%c %cols%
set /a cl+=1
)
set /a cle+=1
call :wait 7
) else call :wait_colorize 500
2>nul (>>"%temp%\wait.tmp" call )||goto :repeat
)
goto :End_Main
rem fare un echo con una sola linea! lasciare le variabili str nell'echo. Si risparmia rispetto al set/p.
:press pos nlines
(
set ne=%2
mode %cols%,%lines%
For /L %%l in (1,1,%1) do echo(
if !ne! equ 13 (<nul set /p "=!s1!!str1:~0,72!!s2!!str2:~0,72!!s3!!str3:~0,72!!s4!!str4:~0,72!!s5!"
) else (
for %%m in (
"Û²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²Û"
"Û²±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±²Û"
"Û²±°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°±²Û"
"Û²±° °±²Û"
"²±° °±²"
"±° !str1:~0,72! °±"
"° !str2:~0,72! °"
"±° !str3:~0,72! °±"
"²±°!str4:~0,72!°±²"
"Û²±° °±²Û"
"Û²±°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°±²Û"
"Û²±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±²Û"
"Û²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²Û"
) do (
if !ne! gtr 0 <nul set /p "=%%~m"
set /a ne-=1
)
)
set str1=!str1:~1!!str1:~0,1!
set str2=!str2:~1!!str2:~0,1!
set str3=!str3:~1!!str3:~0,1!
set str4=!str4:~1!!str4:~0,1!
goto :eof
)
:blinking_line pos finalcolor len [/n]
(
set t0=!time!
For %%. in (8 7 f 7 7 8 8 8 8 %2) do (
mode %cols%,%lines%
For /L %%l in (1,1,%1) do echo(
call :ColorText_bg_BS %%. %3 %4
for /F "tokens=1-8 delims=:.," %%a in ("!t0: =0!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31) & 8640000"
set /a a=5-a
if !a! gtr 0 call :wait !a!
set t0=!time!
)
goto :eof
)
rem utile per riscrivere una linea senza lasciare lo spazio vuoto. Usa BS al posto di DEL.
rem Per len <=1 non funziona.
rem Non usare se si desidera stampare a destra perche' il BS tornato indietro fa sovrascrivere l'ultimo colore stampato
:ColorText_bg_BS bg_color len [/n]
(
set /a "len=%2-1"
if !len! geq 1 for %%. in (!len!) do findstr /v /a:%1%1 /R "^$" "!str_findstr:~0,%%.!" nul
if /i "%~3"=="/n" echo(
goto :eof
)
:wait_colorize
rem avvia ping
start "" /B ping 192.0.2.0 -n 1 -w 500 >>"%temp%\wait_colorize.tmp" 2>nul
For /L %%l in (1,1,6) do echo(
:repeat_colorize
call :ColorText_bg_BS 4 76
<nul set /p "=!BS!!CR!"
2>nul (>>"%temp%\wait_colorize.tmp" call )||goto :repeat_colorize
goto :eof
:wait time_cs time
(
if %1 gtr 100 (ping 192.0.2.0 -n 1 -w %1 >nul & goto :eof)
set t0=!time!
:wait_loop
for /F "tokens=1-8 delims=:.," %%a in ("!t0: =0!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31) & 8640000"
if !a! lss %1 goto :wait_loop
goto :eof
)
:init_system
rem passa alla directory temporanea
pushd "%temp%"
for /f %%a in ('copy /Z "%~dpf0" nul') do set "CR=%%a"
rem genero il DEL
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
:: Define BS to contain a backspace
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
rem larghezza schermo
set /a cols=78, lines=43
rem preparo una stringa lunga %cols% caratteri
set "str_findstr="
For /L %%c in (1,1,%cols%) do set "str_findstr=!str_findstr!L"
rem creo tutte le possibili lunghezze
For /L %%l in (1,1,%cols%) do <nul set /p .=%BS%> "!str_findstr:~0,%%l!"
set "str1= ____ ____ ____ ____ ____ __ __ _ _ _ __ _ ____ _ _ "
set "str2=( _ \( _ \( __)/ ___)/ ___) / _\ ( ( \( \/ ) ( / )( __)( \/ ) "
set "str3= ) __/ ) / ) _) \___ \\___ \ / \/ / ) / ) ( ) _) ) / "
set "str4=(__) (__\_)(____)(____/(____/ \_/\_/\_)__)(__/ (__\_)(____)(__/ "
set "s1="
for %%m in (
"Û²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²Û"
"Û²±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±²Û"
"Û²±°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°±²Û"
"Û²±° °±²Û"
"²±° By Einstein1969 °±²"
"±° ") do set s1=!s1!%%~m
set "s2="
for %%m in ( " °±"
"° ") do set s2=!s2!%%~m
set "s3="
for %%m in ( " °"
"±° ") do set s3=!s3!%%~m
set "s4="
for %%m in ( " °±"
"²±°") do set s4=!s4!%%~m
set "s5="
for %%m in ( "°±²"
"Û²±° °±²Û"
"Û²±°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°±²Û"
"Û²±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±²Û"
"Û²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²Û") do set s5=!s5!%%~m
goto :Main
:End_Main
popd
Goto :eof
einstein1969