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!
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
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 ]
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.
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?
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.
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
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
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 ]
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