Has anyone heard from einstein1969? I have a script he wrote, and as I'm looking through the code I find something I don't quite understand, and was hoping someone could explain it to me.

Here is einstein1969's Heartbeat.bat, works perfectly fine here on win10.

Code: Select all

```
@echo off
setlocal EnableDelayedExpansion
if not "%1"=="" goto :%1
color 0f
mode 72,71
chcp 850
ping -n 2 127.0.0.1 >nul
"%~f0" HB 24 10 | find "TTL" | "%~f0" MAIN 4
exit /b
:MAIN
for /f "delims==" %%v in ('set') do set "%%v="
set /A "xres=70, yres=70
for /l %%y in (1 1 !yres!) do (
set "Lines%%y="
for /l %%x in (1 1 !xres!) do set "lines%%y=!lines%%y! "
)
set g=.Û
:: PI=31416
set "SIN=a-a*a/1920*a/312500+a*a/1920*a/15625*a/15625*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000"
set "SIN(x)=(a=(x)%%62832, c=(a>>31|1)*a, a-=(((c-47125)>>31)+1)*((a>>31|1)*62832) + (-((c-47125)>>31))*( (((c-15709)>>31)+1)*(-(a>>31|1)*31416+2*a) ), %SIN%)"
set "SIN="
set /A Angle=0, Radius=xres/2-2
set t0=%time%
(
Rem Empty Env, use percent expand.
set SIN(x^)=
set xres=
set yres=
set Radius=
for /L %%N in (0) do (
set/p =
set/p =
set /a "t=1!time:~6,2!!time:~9,2!-10000, dt=t-(oldt+0), dt+=(dt>>31)&6000" >NUL
if !dt! geq %2 (
cls & for /l %%? in (1, 1,%yres%) do echo( !Lines%%?!
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, angle=a/2"
rem set /A Angle+=3
For /L %%y in (0,1,%yres%) do (
set Lines%%y=!Lines%%y:°= !
set Lines%%y=!Lines%%y:±=°!
set Lines%%y=!Lines%%y:²=±!
set Lines%%y=!Lines%%y:Û=²!
)
set /A "x1=%Xres%/2, y1=%Yres%/2, x2=%Xres%/2+%SIN(x):x=15708-Angle*31416/180%*%Radius%/10000, Y2=%Yres%/2+%SIN(x):x=Angle*31416/180%*%Radius%/10000, dx=x2-x1, dx=dx*(dx>>31|1), dy=y2-y1, dy=dy*(dy>>31|1)"
if !dy! leq !dx! (
if !x2! lss !x1! set /A t=x2, x2=x1, x1=t, t=y2, y2=y1, y1=t
if !y2! gtr !y1! (
set /A yincr=1
) else set /A yincr=-1
set /a "d=2*dy-dx, Eincr=2*dy, NEincr=2*(dy-dx)"
For /F usebackq^ tokens^=1-3 %%x in ('!x1! !y1! 1') do set c=!Lines%%y:~%%x!& set "Lines%%y=!Lines%%y:~0,%%x!!g:~%%z,1!!c:~1!"
set /A x1+=1
for /L %%X in (!x1!,1,!x2!) do (
if !d! lss 0 (
set /A d+=Eincr
) else set /A d+=NEincr, y1+=yincr
For /F usebackq^ tokens^=1-3 %%x in ('%%X !y1! 1') do set c=!Lines%%y:~%%x!& set "Lines%%y=!Lines%%y:~0,%%x!!g:~%%z,1!!c:~1!"
)
) else (
if !y2! lss !y1! set /A t=x2, x2=x1, x1=t, t=y2, y2=y1, y1=t
if !x2! gtr !x1! (
set /A yincr=1
) else set /A yincr=-1
set /a "d=2*dx-dy, Eincr=2*dx, NEincr=2*(dx-dy)"
For /F usebackq^ tokens^=1-3 %%x in ('!x1! !y1! 1') do set c=!Lines%%y:~%%x!& set "Lines%%y=!Lines%%y:~0,%%x!!g:~%%z,1!!c:~1!"
set /a y1+=1
for /L %%Y in (!y1!,1,!y2!) do (
if !d! lss 0 (
set /a d+=Eincr
) else set /A d+=NEincr, x1+=yincr
For /F usebackq^ tokens^=1-3 %%x in ('!x1! %%Y 1') do set c=!Lines%%y:~%%x!& set "Lines%%y=!Lines%%y:~0,%%x!!g:~%%z,1!!c:~1!"
)
)
set /a oldt=t >NUL
)
)
)
exit/b
:HB
for /L %%N in (0,1,%2) do (
pathping -n -q 1 -p %3 127.0.0.1 >nul
start "HBPING" /B ping -n %2 127.0.0.1
)
for /L %%N in (0) do (
ping -n 2 127.0.0.1 >nul
start "HBPING" /B ping -n %2 127.0.0.1
)
exit /b
```

Code: Select all

```
For /F usebackq^ tokens^=1-3 %%x in ('!x1! !y1! 1') do set c=!Lines%%y:~%%x!& set "Lines%%y=!Lines%%y:~0,%%x!!g:~%%z,1!!c:~1!"
But more particularly this portion
For /F usebackq^ tokens^=1-3
```