Program a Binary Clock in Batch - Binäre Uhr in Batch programmieren

... komplette Frage anzeigen

1 Antwort

Das war das, was ich gefunden hab, mir zu unübersichtlich:

mode con: cols=80 lines=3
@echo Batch File Binary Clock by Eddie Duncan-Dunlop 2010 (c)

:start
@echo off
:::::::: get time ::::::::::::::::::

@For /F "tokens=1,2,3 delims=:,. " %%A in ('echo %time%') do @(
Set _hr=%%A
Set _min=%%B
Set _Sec=%%C
)

:::::::::::: convert Time to binary 8 bits each ::::::::::::::::::
set binary=
set decimal=%_hr%
for /L %%n in (7,-1,0) do call :loop %%n

set decimal=%_min%
for /L %%n in (7,-1,0) do call :loop %%n

set decimal=%_sec%
for /L %%n in (7,-1,0) do call :loop %%n

::::::::::::::: display at top of window ::::::::::::::::::::::::::::::::::
cls
echo %_hr%:%_min%:%_sec% = %binary%

::::::::::::::: Read again till seconds change ::::::::::::::::::::::::
:read
@For /F "tokens=1,2,3 delims=:,. " %%A in ('echo %time%') do @(
Set _h2r=%%A
Set _min2=%%B
Set _Sec2=%%C
)

if NOT %_sec2%==%_sec% goto start
if %_sec2%==%_sec% goto read

:::::::::Subroutine called Loop Starts here:::::::
:loop

:::: store number entered ::::
set store=%decimal%

::: remove leading zero if under 10::::::::::::
if %decimal% lss 10 set decimal=%store:0=%

:: make loop number=1,2,4,8,16,32,64 ...
set /a power="1<<%1"

:: subtract power number from decimal
set /a decimal-=%power%

if %decimal% GEQ 0 set binary=%binary%1

if NOT %decimal% GEQ 0 (
set binary=%binary%0
set decimal=%store%
)

:::::: add a gap every 4 bits (nibble) for clarity ::::::::
set gap=%1
set /a gap="gap%%4"
if "%gap%"=="0" set binary=%binary%
goto :eof

nur zahlen, total unübersichtlich und farblos ... völlig kalt und nich einladend ... daher meine idde, eine bunte uhr in tabellenform, besser ablesbar

Antwort bewerten Vielen Dank für Deine Bewertung

Was möchtest Du wissen?