本帖最后由 Src 于 2023-5-27 09:46 编辑
参照了好多Bathome的代码- @ echo off
- setlocal enabledelayedexpansion
- cd /d "%~dp0"
- title Lhsude 计算器问题报告
- if not exist %Cd%\Buglist.rid (
- echo 系统文件损毁,请重新安装
- pause>nul&exit
- )
- set n=%1
- if not defined n (
- echo 参数未定义
- pause>nul&exit
- )
- set "return=Fail"
- for /f "delims=:" %%i in ('type "Buglist.rid" ^| findstr /n /l /c:"%n%"') do (
- set "return=%%i"
- )
- if "%return%"=="Fail" echo 故障&goto :eof
- set line=%return%
- echo,参见手册%line%行:
- set "SrcFile=%Cd%\Buglist.rid"
- REM 获取第几行
- set "DstRow=%line%"
- for /f "tokens=1* delims=:" %%i in ('findstr /n .* "%SrcFile%"') do (
- set /a "CurRow+=1"
- if !CurRow! equ %DstRow% (
- echo,%%j
- goto :End
- )
- )
-
- :End
- goto :eof
复制代码 同目录下Read.bat- @echo off&SetLocal ENABLEDELAYEDEXPANSION
- if "%1"=="" (goto --help) else (set file=%~s1)
- if "%2"=="" (set first="delims=: tokens=1*") else (set first="skip=%2 delims=: tokens=1*")
- if "%3"=="" (
- for /f %first% %%a in ('findstr /n .* %file%') do echo/%%b
- goto :EOF
- )
- set last=%3
- set loop=0
- for /f %first% %%a in ('findstr/n .* %file%') do (
- if not defined lxmxn (echo/%%b&set /a loop+=1) else (goto :EOF)
- if "!loop!"=="%last%" set lxmxn=Nothing
- )
- GOTO :EOF
-
- :--help
- echo/======================================
- echo/本程序段需要带参数才能正常运行
- echo/&echo/Usage:&echo/Call ReadLine ^<文件名^> ^<跳过行数^> ^<读取行数^>
- echo/&echo/例如:call ReadLine aa.txt 5 7 ,将跳过aa.txt文件的前5行,读取下面的7行字符
- echo/&echo/如果^<跳过行数^>没有指定,就从文件第一行读取
- echo/&echo/指定^<读取行数^>时必须指定^<跳过行^>
- echo/======================================
- goto :eof
复制代码 Buglist.rid- [Data]
- 1:请检查目录名称是否合法,文件是否存在,文件名是否被更改。
- 2:目录为空。
- 3:这是第三个
- =End of textdata=
复制代码
|