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-08-06 06:20
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to implement a copy operation View 687 Replies 6
Original Poster Posted 2007-10-28 18:06 ·  中国 广东 深圳 英达通信
初级用户
Credits 52
Posts 20
Joined 2007-10-25 14:22
18-year member
UID 100747
Gender Male
Status Offline
What I want is to enter a sentence myself, and then display it 100 times on the screen.
Could an expert please teach me?
Floor 2 Posted 2007-10-28 18:17 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

@echo off
Set /p hello=Enter the text you want to repeat:
for /L %%a in (1,1,100) do echo %hello%
pause
Floor 3 Posted 2007-10-28 18:26 ·  中国 广东 深圳 英达通信
初级用户
Credits 52
Posts 20
Joined 2007-10-25 14:22
18-year member
UID 100747
Gender Male
Status Offline
Can you explain to me
what set /p means?
Floor 4 Posted 2007-10-28 18:29 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
“set /p string=Please enter” means prompting the user to enter a string (“Please enter”), and then assigning the substring entered by the user to the variable (string) that follows.
Floor 5 Posted 2007-10-28 18:35 ·  中国 广东 深圳 英达通信
初级用户
Credits 52
Posts 20
Joined 2007-10-25 14:22
18-year member
UID 100747
Gender Male
Status Offline
I understand now, but why
wasn't the “Enter the text you want to repeat:” you wrote executed?
Floor 6 Posted 2007-10-28 18:39 ·  中国 广东 深圳 英达通信
初级用户
Credits 52
Posts 20
Joined 2007-10-25 14:22
18-year member
UID 100747
Gender Male
Status Offline
I get it now. After trying it once, I understand: string is the input variable, while what you type there is only for display, and isn't within the scope of string... Am I understanding it right? Thanks, moderator..
Floor 7 Posted 2007-10-28 20:26 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Your understanding is absolutely correct!
Forum Jump: