• Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

Draw a box

Assaultz

Member
m0X6gQC.png




CODE :

[HIDE]@echo off&& setlocal&& cls
REM Draws a rectangle with X1, Y1, Width and Height specified by inputs
set "x=%1"&& set "y=%2"&& set "w=%3"&& set "h=%4"

REM Place blank lines above
set /a yBefore=%y% - 1
for /l %%a in (1,1,%yBefore%) do (echo.)

REM Create rectangle components
set /a xRemaining=%x%-1
set wRemaining=%w%
:topLineGen
if NOT %xRemaining% == 0 set /a xRemaining-=1&& set "topLine=%topLine% "&& goto :topLineGen
set "topLine=%topLine%#"&& set /a wRemaining-=1
if NOT %wRemaining% == 0 goto :topLineGen

REM Render top line
echo %topLine%

REM Create middle line
set xRemaining=%x%
set /a wRemaining=%w%-2
:midLinePreGen
if %xRemaining% GTR 1 set /a xRemaining-=1&& set "midLine=%midLine% "&& goto :midLinePreGen
set "midLine=%midLine%#"
:midLineGen
if %wRemaining% GTR 0 set /a wRemaining-=1&& set "midLine=%midLine% "&& goto :midLineGen
if %w% GTR 1 set "midLine=%midLine%#"

REM Render middle lines
set /a midLinesRemaining=%h%-2
:renderMidLines
if %midLinesRemaining% GTR 0 echo %midLine%&& set /a midLinesRemaining-=1&& goto :renderMidLines

REM If the height is greater than 1, render a bottom line (we can re-use %topLine% variable)
if %h% GTR 1 echo %topLine%
endlocal
exit /b
[/HIDE]

Enjoy :P
 
General chit-chat
Help Users
  • No one is chatting at the moment.
      Chat Bot: ariel157 is our newest member. Welcome!
      Back
      Top