-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgobsprogram.cmd
35 lines (35 loc) · 977 Bytes
/
gobsprogram.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@echo off
color 0A
set p="Penus "
setlocal EnableDelayedExpansion
rem Default choice output does not meet program requirements
echo Gob's Program: Y/N?
echo | set /p="? "
choice /M "" >NUL
if %ERRORLEVEL% EQU 1 (
echo Y
rem Fetch console width from "con"
for /F "usebackq tokens=2* delims=: " %%W in (`mode con ^| findstr Columns`) do set CONSOLE_WIDTH=%%W
:loop
rem Echo as many double-spaced penii as possible
for /L %%a in (7,7,!CONSOLE_WIDTH!) do (
echo | set /p=%p%
set /a PENUS_WIDTH="%%a"
)
rem Can we squeeze in a penus without double-spacing?
set /a TEST_WIDTH=PENUS_WIDTH+5
if !TEST_WIDTH! LEQ !CONSOLE_WIDTH! (
if !TEST_WIDTH! EQU !CONSOLE_WIDTH! (
rem CMD would wrap a CRLF onto a new line, avoid this
echo | set /p=%p:~1,5%
) else (
echo %p:~1,5%
)
) else (
rem CMD would wrap a CRLF onto a new line, avoid this if necessary
if !PENUS_WIDTH! NEQ !CONSOLE_WIDTH! (
echo.
)
)
goto loop
)