Just as 3742668 said, the format of the lexicon is very important. To find matching content in the lexicon using CMD, findstr is the best choice. A preliminary code is written, requiring the format of the lexicon to be: each word occupies one line (case - insensitive); the translation content starts a new line (pure - letter lines are not allowed), and there can be multiple lines.
Code:
Test content format example:
Those interested can use more content for testing.
[ Last edited by namejm on 2006 - 10 - 12 at 08:19 ]
Code:
@echo off
:begin
cls
set input=
set /p input=Please enter the word to be searched (press Enter directly to exit):
if not defined input exit
for /f "tokens=1,2 delims=:" %%i in ('findstr /n. test.txt') do (
if /i "%%j"=="%input%" (set line=%%i&&goto display)
)
echo _________________________________
echo.
echo No record of %input% found
echo _________________________________
echo.
pause
goto begin
:display
echo _________________________________
echo.
echo %input%:
for /f "skip=%line% tokens=*" %%i in (test.txt) do (
echo %%i|findstr "^*$">nul &&goto end||echo %%i%
)
:end
echo _________________________________
echo.
pause
goto begin
Test content format example:
China
n.
China, porcelain
DOS
n.
Disk operating system
name
n.
name, name, name, reputation
vt.
name, nominate, call out, designate
adj.
name - related, named - after
who
pron.
who, the one... (person)
Those interested can use more content for testing.
[ Last edited by namejm on 2006 - 10 - 12 at 08:19 ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
考虑问题复杂化,解决问题简洁化。

DigestI