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-12 05:52
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to limit the value range in a batch file View 628 Replies 2
Original Poster Posted 2009-06-28 04:46 ·  中国 云南 昆明 电信
初级用户
Credits 36
Posts 25
Joined 2009-06-01 08:44
17-year member
UID 146434
Gender Male
Status Offline
For example: get a number between 1 and 9
Please advise
Floor 2 Posted 2009-06-28 08:02 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
Use remainder...

@echo off
set /a han=%random%%%9+1
echo %han%
pause


[ Last edited by Hanyeguxing on 2009-6-28 at 08:10 ]
Floor 3 Posted 2009-06-29 03:03 ·  中国 广东 揭阳 移动
初级用户
★★
Credits 131
Posts 72
Joined 2008-02-24 14:31
18-year member
UID 111317
Gender Male
Status Offline
An if check will do

Greater than the smaller one, less than the larger one... then it's valid input
Forum Jump: