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 19:49
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » DOS clock made while working on the job View 2,112 Replies 18
Original Poster Posted 2008-03-10 18:30 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
You can add a reminder function, such as reminding what to do when a certain time comes. Due to my time constraints, I posted in a hurry, please bear with me and put forward valuable opinions. The purpose of each of my posts is to focus on the theme of common improvement. The code is as follows:
@echo off
:begin
mode con cols=40 lines=3&setlocal EnableDelayedExpansion
title dos clock
set /a a=%random%/3640&set /a b=%random%/3640
cls&color %a%%b%&echo.&echo.&echo.&echo    %date% !time:~-11,-3!&ping/n 2 127.1 >nul
goto begin
Floor 2 Posted 2008-03-10 18:52 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
Added reminder function and modified error codes:
@echo off&setlocal EnableDelayedExpansion
:begin
mode con cols=40 lines=3
title dos clock
set t=!time:~-11,-6!
if "%t%"=="18:00" goto show
set /a a=%random%/3640&set /a b=%random%/3640
cls&color %a%%b%&echo.&echo.&echo.&echo    %date% !time:~-11,-3!&ping/n 2 127.1 >nul
goto begin
:show
cls&color 9f&echo.&echo.&echo.&echo    It's time to get off work!
goto begin

[ Last edited by zw19750516 on 2008-3-10 at 07:14 PM ]
Floor 3 Posted 2008-03-10 19:51 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
The building owner is really cute, I guess it's a girl (I have no bad intentions)
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 4 Posted 2008-03-10 20:03 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
Only after checking the information did I realize the original poster is a handsome guy. Sorry about that. The post has great ideas, so I'll give a thumbs up here.
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 5 Posted 2008-03-10 22:27 ·  中国 福建 福州 连江县 联通
高级用户
★★
Credits 581
Posts 277
Joined 2006-12-23 05:10
19-year member
UID 74328
Gender Male
Status Offline
Tested it, and the effect is pretty good
Floor 6 Posted 2008-03-12 19:14 ·  中国 黑龙江 大庆 大庆中基石油通信建设有限公司
高级用户
★★
Credits 547
Posts 261
Joined 2006-04-15 16:50
20-year member
UID 53887
Status Offline
Originally posted by zw19750516 at 2008-3-10 18:52:
Added reminder function and modified error code:
@echo off&setlocal EnableDelayedExpansion
:begin
mode con cols=40 lines=3
title dos clock
set t=!time:~-11,-6!
if "%t%"==&quo ...


Spent two hours thinking I understood the %var:~1,5% usage of set, but how to understand
=!time:~-11,-6!
For example, the result of entering the time command is:
18:20:55.75
How to intercept it?
Floor 7 Posted 2008-03-12 20:10 ·  中国 广东 广州 海珠区 电信
初级用户
★★
Credits 131
Posts 119
Joined 2007-06-12 22:50
19-year member
UID 91125
Gender Male
From gz
Status Offline
set t=!time:~-11,-6! can be changed to set t=!time! directly
Floor 8 Posted 2008-03-12 22:18 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
Originally posted by tempuser at 2008-3-1期间19:14:


Spent two hours thinking I understood the usage of %var:~1,5% in set, but
=!time:~-11,-6!
How to understand it?
For example, the result of entering the time command is:
18:20:55.75
How to intercept it?

Actually, the system time is composed of 11 characters. The command!time:~-11,-6! means to intercept 11 characters from the time starting from the back and discard 6 characters from the back. For 18:20:55.75, the intercepted characters are 18:20. It seems you are not very familiar with the character interception command. Here is a practice tool for you: http://www.cn-dos.net/forum/viewthread.php?tid=38251&fpage=4, I believe you will be familiar with it in a short time.
Floor 9 Posted 2008-03-13 01:45 ·  中国 河南 郑州 联通
初级用户
Credits 98
Posts 40
Joined 2007-11-17 02:54
18-year member
UID 102890
Gender Male
Status Offline
Floor 10 Posted 2008-03-13 12:12 ·  中国 黑龙江 大庆 大庆中基石油通信建设有限公司
高级用户
★★
Credits 547
Posts 261
Joined 2006-04-15 16:50
20-year member
UID 53887
Status Offline
Originally posted by zw19750516 at 2008-3-12 22:18:

Actually, the system time is composed of 11 characters. The meaning of the!time:~-11,-6! command is to intercept 11 characters from the time's 11 characters from the back and discard 6 characters from the back. For 18:20:55.75 intercepting...

Different understanding, but this tool is not enough to enhance my understanding because there are no negative numbers
I don't know if my understanding is correct, but I still think this understanding is fast. For example, you said
%var:~5,5%
Intercept 5 from the front and 5 from the back
My understanding is
Start from the 6th character, intercept 5 and assign to the variable, no matter right or wrong, but it is very clear
Floor 11 Posted 2008-03-17 18:48 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
@echo off&setlocal EnableDelayedExpansion
:begin
mode con cols=40 lines=3
title dos clock
set t=!time:~-11,-6!
if "%t%"=="12:00" goto show
if "%t%"=="18:00" goto show
set /a a=%random%/2184&set /a b=%random%/2184
if "%a%"=="15" set a=f
if "%a%"=="14" set a=e
if "%a%"=="13" set a=d
if "%a%"=="12" set a=c
if "%a%"=="11" set a=b
if "%a%"=="10" set a=a
if "%b%"=="15" set b=f
if "%b%"=="14" set b=e
if "%b%"=="13" set b=d
if "%b%"=="12" set b=c
if "%b%"=="11" set b=b
if "%b%"=="10" set b=a
cls&color %a%%b%&echo.&echo.&echo.&echo    %date% !time:~-11,-3!&ping/n 2 127.1 >nul
goto begin
:show
cls&color 9f&echo.&echo.&echo.&echo    It's time to get off work!
goto begin
Floor 12 Posted 2008-03-18 20:14 ·  中国 安徽 马鞍山 电信
中级用户
★★
拟谷盗
Credits 312
Posts 108
Joined 2007-01-21 11:36
19-year member
UID 77238
Gender Male
Status Offline
Not bad!
Can be strengthened a bit more. Add sound prompt.
Use bell to ring (enter ctrl+g in cmd)
Or call mshta
mshta vbscript:createobject("sapi.spvoice").speak("time is go home.")(window.close)
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
sonicandy +2 2008-03-22 22:20
FLOSS
Floor 13 Posted 2008-03-19 13:24 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
@echo off&setlocal EnableDelayedExpansion
:begin
mode con cols=40 lines=3
title dos时钟
set t=!time:~-11,-6!
if "%t%"=="12:00" goto show
if "%t%"=="18:00" goto show
set /a a=%random%/2184&set /a b=%random%/2184
if "%a%"=="15" set a=f
if "%a%"=="14" set a=e
if "%a%"=="13" set a=d
if "%a%"=="12" set a=c
if "%a%"=="11" set a=b
if "%a%"=="10" set a=a
if "%b%"=="15" set b=f
if "%b%"=="14" set b=e
if "%b%"=="13" set b=d
if "%b%"=="12" set b=c
if "%b%"=="11" set b=b
if "%b%"=="10" set b=a
cls&color %a%%b%&echo.&echo.&echo.&echo    %date% !time:~-11,-3!&ping/n 2 127.1 >nul
goto begin
:show
cls&color 9f&echo.&echo.&echo.&echo    下班时间到了!
mshta vbscript:createobject("sapi.spvoice").speak("time is go home")(window.close)
goto begin


[ Last edited by zw19750516 on 2008-3-19 at 01:27 PM ]
Floor 14 Posted 2008-03-19 20:51 ·  中国 北京 电信
初级用户
Credits 28
Posts 12
Joined 2007-05-08 17:43
19-year member
UID 87879
Gender Male
Status Offline
Learning mshta vbscript:createobject("sapi.spvoice").speak("time is go home")(window.close)
This is pretty good
Floor 15 Posted 2008-03-19 20:51 ·  中国 北京 电信
初级用户
Credits 28
Posts 12
Joined 2007-05-08 17:43
19-year member
UID 87879
Gender Male
Status Offline
Here is the translation of the provided content:

Here is a VBS script that can speak both Chinese and English.
Set objVoice = CreateObject("SAPI.SpVoice")
Set objVoice.Voice = objVoice.GetVoices("Name=Microsoft Mary").Item(0)
objVoice.Speak "Hi, this is Microsoft Mary"
Wscript.Sleep 2000
Set objVoice.Voice = objVoice.GetVoices("Name=Microsoft Simplified Chinese").Item(0)
objVoice.Speak "Hello, today is Sunday Hi, this is Microsoft Mary"
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
sonicandy +2 2008-03-22 22:21
Forum Jump: