- @echo off
- setlocal enabledelayedexpansion
- set colsnum=70
- set linesnum=22
- MODE con: COLS=%colsnum% lines=%linesnum%
- ::首先将行数和列数都用变量表示
- title Driver Initial
- color 3F
- cls
- set/a colsnum=%colsnum%-5
- ::echo以及其后的空格共占5列
- set myecho=Driver Initial
- ::将你要输出的字符串赋值给变量myecho
- set flag=0
- ::初始化计数器flag
- for /l %%i in (0,1,1000) do (
- set tt=!myecho:~%%i,1!
- if "!tt!" equ "" goto next
- set/a flag=!flag!+1
- )
- ::统计你输入的字符串长度
- :next
- set/a colsnum=!colsnum!-!flag!
- set/a colsnum=!colsnum!/2
- for /l %%i in (1,1,!colsnum!) do (
- set space= !space!
- )
- ::得到字符串前面的n个空格
- echo.
- echo ----------------------------------------------
- echo !space!%myecho%
- echo ----------------------------------------------
- echo.
- echo 操作完毕,按任意键退出...
- pause>nul
- exit
复制代码
|