China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-25 03:02
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Batch processing: Address book View 4,250 Replies 20
Floor 16 Posted 2006-11-17 21:40 ·  中国 北京 东城区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
This picture is interesting, haha~:)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 17 Posted 2006-11-17 23:37 ·  IANA 局域网IP(Private-Use)
中级用户
★★
蝴蝶之吻
Credits 430
Posts 177
Joined 2006-09-20 12:00
19-year member
UID 63170
From 广东深圳
Status Offline
Okay.
More and more functions.
Code is getting simpler and simpler.
Fewer and fewer problems.
Hehe.
Floor 18 Posted 2006-11-18 00:20 ·  中国 北京 东城区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
It is suggested that after each modification and update of a version of the address book, provide a directly downloadable file link in the first post~:) This is convenient for everyone to download and use, and it is also convenient to see the download count to indirectly count the number of netizens interested in this~:) At the same time, only newly registered users can download attachments, so it indirectly increases the number of users who are interested and must register~:)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 19 Posted 2006-11-18 09:13 ·  中国 广东 广州 白云区 电信
新手上路
Credits 4
Posts 2
Joined 2006-11-18 08:52
19-year member
UID 70943
Gender Male
Status Offline
Find the basic posts to read first..
:(
Floor 20 Posted 2006-11-21 15:21 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
11-20 modification: Adopt module method to reduce the same - function scripts, add the function of judging whether the contact exists, and modify the database single - item end and the retrieval method of viewing all contacts
@echo off
title Address Book
mode con cols=80 lines=25
set DisPlay=
setlocal EnableDelayedExpansion
:Main
cls
echo.
echo ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
echo ※                                    ※
echo ※           ☆Welcome to use the command prompt version address book☆           ※
echo ※                                    ※
echo ※      zxcv@bbs.cn-dos.net  zh159@bbs.blueshow.net       ※
echo ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
echo.
echo   ※ Add (N) ※ Delete (D) ※ Modify (M) ※ View all (A) ※ View Tel.db (V) ※
echo.
set input=
set line=
set /p input= Choose (directly enter contact or phone number to query)%DisPlay%:
if not exist Tel.db call :Tel.db
if "%input%" == "" set DisPlay=&goto Main
if /i "%input%" == "n" goto New
if /i "%input%" == "d" goto Del
if /i "%input%" == "m" goto Modify
if /i "%input%" == "a" goto All
if /i "%input%" == "v" goto db

for /f "tokens=1,2,3* delims=:" %%i in ('findstr /nirc:"%input%" Tel.db') do (
if "%%j" == "%input%" set line=%%i
if "%%k" == "%input%" set line=%%i)
if not "%line%" == "" (goto Display) else (
echo __________________________________________________
echo.
echo No record found for %input%
echo __________________________________________________
echo.
pause
set DisPlay=
goto Main)

:Display
echo __________________________________________________
echo.
for /f "skip=%line% delims=" %%i in (Tel.db) do (
if "%%i" == "-End-" goto End
echo %%i
)
:End
echo __________________________________________________
echo.
pause
set DisPlay=
goto Main

:Tel.db
>Tel.db echo ::Address book database
>>Tel.db echo --------------------------------------------------
>>Tel.db echo.
goto :eof

:New
set YN=Y
set check=
echo (Press Enter directly to cancel and return to the main interface)
call :Input
if "%check%" == "Y" set DisPlay=&echo Contact %input% already exists!&echo.&Pause&goto Main
if "%联系人姓名%" == "" set DisPlay=&goto Main
call :Newdb
set DisPlay=(Add new contact: %联系人姓名%)
goto Main

:Del
set YN=N
set check=
echo (Press Enter directly to cancel and return to the main interface)
echo.
set /p 删除联系人= Delete contact:
if "%删除联系人%" == "" set DisPlay=&goto Main
set input=%删除联系人%
call :Check
if "%check%" == "N" set DisPlay=&echo Contact %input% does not exist!&echo.&pause&goto Main
call :Deldb
set DisPlay=(Contact %删除联系人% has been deleted)
goto Main

:Modify
set YN=N
set check=
echo (Press Enter directly to cancel and return to the main interface)
echo.
set 修改联系人姓名=
set /p 删除联系人= Modify contact name:
set input=%删除联系人%
call :Check
if "%check%" == "N" set DisPlay=&echo Contact %input% does not exist!&echo.&pause&goto Main
if "%删除联系人%" == "" set DisPlay=&goto Main
echo Modify to:
call :Input
if "%联系人姓名%" == "" set DisPlay=&goto Main
call :Deldb
call :Newdb
set DisPlay=(Contact %删除联系人% has been modified)
goto Main

:All
cls
echo.
echo All contacts in the address book:
echo.
set N=
for /f "skip=3 delims=" %%i in (Tel.db) do (
set All=%%i
if "!All:~-2!" == "::" set /a N+=1&set AllShow=!All:::=!&&echo !AllShow::= Phone: !
set /a Page=!N!%%19
if "!Page!" == "0" if "!All:~-2!" == "::" call :AllPaus)
echo.
pause
goto Main

:db
start notepad Tel.db
goto Main

:Input
echo.
set 联系人姓名=
set 联系人电话=
set 联系人单位=
set 联系人地址=
set /p 联系人姓名= Contact name:
if "%联系人姓名%" == "" goto :eof
set input=%联系人姓名%
call :Check
if "%check%" == "%YN%" goto :eof
set /p 联系人电话= Contact phone number:
set /p 联系人地址= Contact unit:
set /p 联系人单位= Contact address:
goto :eof

:Newdb
>>Tel.db echo %联系人姓名%:%联系人电话%::
>>Tel.db echo Contact name: %联系人姓名%
>>Tel.db echo Contact phone number: %联系人电话%
if not "%联系人单位%" == "" >>Tel.db echo Contact unit: %联系人单位%
if not "%联系人地址%" == "" >>Tel.db echo Contact address: %联系人地址%
>>Tel.db echo -End-
>>Tel.db echo.
goto :eof

:Deldb
move/y Tel.db TelBak.db
call :Tel.db
set Delete=echo
for /f "skip=3 delims=" %%i in (TelBak.db) do (
for /f "tokens=1* delims=:" %%n in ("%%i") do (
if "%%n" == "%删除联系人%" set Delete=rem
>>Tel.db !Delete! %%i
if "%%i" == "-End-" >>Tel.db !Delete!.&&set Delete=echo
))
goto :eof

:AllPaus
echo.
set Paus=
set /p Paus= Press Enter to continue to the next page (B returns to the main interface)...
if /i "%Paus%" == "b" goto Main
cls
echo.
echo All contacts in the address book:
echo.
goto :eof

:Check
for /f "tokens=1,2,3* delims=:" %%i in ('findstr /nirc:"%input%" Tel.db') do (
if "%%j" == "%input%" set line=%%i
if "%%k" == "%input%" set line=%%i)
if not "%line%" == "" (goto CheckDisplay) else (
echo.
set check=N
goto :eof)

:CheckDisplay
echo __________________________________________________
echo.
for /f "skip=%line% delims=" %%i in (Tel.db) do (
if "%%i" == "-End-" goto CheckEnd
echo %%i
)
:CheckEnd
echo __________________________________________________
echo.
set check=Y
goto :eof
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +3 2006-11-21 23:02
Floor 21 Posted 2006-11-21 23:04 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
If you want to make a video teaching film on how to write this address book, and while talking, demonstrate and explain the principles at the same time, and then publicly release it to various website download areas as part of the batch processing teaching film, that would be great~ :)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Forum Jump: