Final Integration...
The code on floor 20 is completely error-free. I want to add some command processing on the original basis, but there is something wrong with the code I wrote, so I need to trouble you again, and integrate them together.
I want to perform these processes on the original basis:
1. Also display what is entered
2. After input, first make these judgments:
If:
Press Enter directly, then execute the command
If the input is /h, then execute the command and exit
If the input is /s, then execute the command and exit
If the input is /r, then execute the command and exit
Then judge the following:
If it starts with /h, then intercept the characters after /h, and then execute the command
If it starts with /s, then intercept the characters after /s, and then execute the command
The following is the code I modified:
■: Original code on floor 20 ■: What I added
@echo off
setlocal enabledelayedexpansion
:bgn
del t_.txt 1>nul 2>nul
set "n="&set "count="
set /p str=Please enter:
if not defined str goto 11
If %str%==/h 执行命令 & exit
If %str%==/s 执行命令 & exit
If %str%==/r 执行命令 & exit
if /i "%str:~,2%"=="/h" (
set str=%str:~2%
执行命令
goto settext
)
if /i "%str:~,2%"=="/s" (
set str=%str:~2%
执行命令
)
:settext
set Text=%str%
:agn
set st=!str:~,1!
>>t_.txt echo.!st!
if not "!str:~1!"=="" (set "str=!str:~1!"&goto :agn)
>>t_.txt echo god
for /f "delims=:" %%a in ('findstr /o .* t_.txt') do (
set /a "n+=1","m=n-1"
set "_!n!=%%a"
if !n! geq 2 (
call set /a "var=%%_!n!%%-%%_!m!%%"
if !var! equ 4 (set /a count+=19) else (set /a count+=10)
)
)
echo %count%
echo %text%
goto :bgn
:11
...
The test result is that there will be an error if there is a space.
(The error is not elsewhere, just in the part I added that the operation is interrupted)
[ Last edited by tireless on 2008-9-21 at 01:53 AM ]