After looking at zouzhxi's DOS version address book, I have some ideas:
Latest modification on floor 20:
Modified from 11-20: Adopt module method to reduce scripts with the same function, add the function of judging whether the contact exists, and modify the single item ending and the retrieval method for viewing all contacts
The search display of version by namejm (modified the single item ending retrieval method):
Batch processing to delete a certain record
Tel.db Address book database
Add single item
[ Last edited by zxcv on 2006-11-21 at 03:20 AM ]
Latest modification on floor 20:
Modified from 11-20: Adopt module method to reduce scripts with the same function, add the function of judging whether the contact exists, and modify the single item ending and the retrieval method for viewing all contacts
The search display of version by namejm (modified the single item ending retrieval method):
@echo off
:: The format of the thesaurus is: the word occupies one line (case-insensitive);
:: The translated content starts a new line (no pure letter lines are allowed), and there can be multiple lines.
:begin
cls
set input=
set line=
set /p input=Please enter the word to be searched (press Enter directly to exit):
if not defined input exit
for /f "tokens=1* delims=:" %%i in ('findstr /nirc:"^%input%" Tel.db') do (if /i "%%j"=="%input%" set line=%%i)
if not "%line%"=="" (goto display) else (
echo _________________________________
echo.
echo No record found for %input%
echo _________________________________
echo.
pause
goto begin)
:display
echo _________________________________
echo.
echo %input%:
for /f "skip=%line% delims=" %%i in (Tel.db) do (
if "%%i"=="::" goto end
echo %%i
)
:end
echo _________________________________
echo.
pause
goto begin
Batch processing to delete a certain record
@echo off
echo.
set /p DeletePerson= Delete person:
>TelN.db echo ::Address book database
>>TelN.db echo --------------------------------------------------
>>TelN.db echo.
setlocal EnableDelayedExpansion
for /f "delims=" %%i in (Tel.db) do (
if "%%i" == "::" set /a Num+=1
)
set Delete=echo
for /f "skip=3 delims=" %%i in (Tel.db) do (
if "%%i" == "%DeletePerson%" set Delete=rem&&set /a N-=1
!Delete! %%i>>TelN.db
if "%%i" == "::" !Delete!.>>TelN.db&&set /a N+=1&&cls&&echo.&&echo !N!/%Num%&&set Delete=echo
)
pause
del Tel.db
ren TelN.db Tel.db
exit
Tel.db Address book database
::Address book database
--------------------------------------------------
Zhang San
Contact name: Zhang San
Contact phone: Zhang San
Contact address: Zhang San
Contact unit: Zhang San
::
Li Si
Contact name: Li Si
Contact phone: Li Si
Contact address: Li Si
Contact unit: Li Si
::
Wang Wu
Contact name: Wang Wu
Contact phone: Wang Wu
Contact address: Wang Wu
Contact unit: Wang Wu
::
Add single item
set ContactName=
set ContactPhone=
set ContactUnit=
set ContactAddress=
set...
set /p ContactName=Contact name:
set /p ContactPhone=Contact phone:
set /p ContactAddress=Contact unit:
set /p ContactUnit=Contact address:
set /p...
>>Tel.db echo %ContactName%
>>Tel.db echo Contact name: %ContactName%
>>Tel.db echo Contact phone: %ContactPhone%
if not "%ContactUnit%"=="" >>Tel.db echo Contact unit: %ContactUnit%
if not "%ContactAddress%"=="" >>Tel.db echo Contact address: %ContactAddress%
if...
>>Tel.db echo ::
>>Tel.db echo.
[ Last edited by zxcv on 2006-11-21 at 03:20 AM ]



Forgot this