Advertisement
Guest User

Untitled

a guest
Jan 13th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.28 KB | None | 0 0
  1. @echo off & setlocal enableDelayedExpansion
  2.  
  3.     call :grid /F 3 "3x5" /s
  4.     call :display
  5.  
  6. pause & exit
  7.  
  8. :grid
  9.     for /l %%a in (0,1,%gridMaxHeight%) do set "line[%%a]="
  10.     for %%a in (gHeight gWidth gridMaxHeight gridMaxWidth bHeight bWidth i g s d z) do set "%%a="
  11.     set "_t=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
  12.     set /a "gHeight=%2"
  13.     set "z=%1" & set "z=!z:~1,1!"
  14.     for %%a in (%_t%) do set /a "i+=1" & if /i "%%a" equ "%z%" set "gWidth=!i!"
  15.     for /f "tokens=1,2 delims=x" %%a in ("%~3") do set /a "bHeight=%%a + 1", "bWidth=%%b"
  16.     set /a "gridMaxWidth=((gWidth * bWidth) + bWidth)", "gridMaxHeight=(gHeight * bHeight) + 1"
  17.     set /a  "g=gridMaxWidth - bWidth + gWidth + 1"
  18.     for /l %%a in (1,1,%bWidth%) do set "s=!s! "
  19.     for /l %%a in (1,%bWidth%,%gridMaxWidth%) do set "d=!d!!s!#"
  20.     for /l %%a in (1,1,%gridMaxHeight%) do set "line[%%a]=#!line[%%a]!!d:~0,-%bWidth%!"
  21.     for /l %%a in (1,1,%g%) do set "line[0]=!line[0]!#"  
  22.     for /l %%a iN (1,%bHeight%,%gridMaxHeight%) do set "line[%%a]=!line[0]!"
  23.     if "%~4" equ "/s" set "ol=GRID: %gridMaxHeight%x%gridMaxWidth%/[A-%z%] x %gHeight%. - %~3 boxes"  
  24. goto :eof
  25.  
  26. :display
  27.     cls
  28.     if defined ol echo !ol!
  29.     for /l %%a in (1,1,%gridMaxHeight%) do echo=!line[%%a]!
  30. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement