![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-23 12:26 |
47,812 topics / 349,917 posts / today 0 new / 48,273 members |
| DOS批处理 & 脚本技术(批处理室) » [Solved] Ask about the usage of the system variable random |
| Printable Version 2,295 / 3 |
| Floor1 acaigg | Posted 2011-01-20 20:08 |
| 初级用户 Posts 92 Credits 115 | |
|
I searched the forum for a long time and still didn't figure out the usage of random. What do these mean?
set /a %%av=!random!%%40*2,%%ai=!random!%%30 set /a f=%random%%%14+1 Thanks!!! [ Last edited by acaigg on 2011-1-24 at 20:10 ] |
|
| Floor2 liion631818 | Posted 2011-01-22 17:14 |
| 新手上路 Posts 11 Credits 13 From 上海 | |
|
Your code is wrong. There is no system variable called random. It must be a random variable set in the script.
|
|
| Floor3 Hanyeguxing | Posted 2011-01-22 17:43 |
| 银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂 | |
|
%RANDOM% returns any decimal number between 0 and 32767, generated by Cmd.exe.
%% is the modulus in batch set/a, that is, to get the remainder. Using random, remainder, etc. in set/a is to make the obtained variable a regular random number. set/a i=!random!%%30, i is a random number between 0 and 29; set/a v=!random!%%40*2, v is an even number between 0 and 78; set/a f=%random%%%14+1, f is a random number between 1 and 14. |
|
| Floor4 acaigg | Posted 2011-01-24 19:52 |
| 初级用户 Posts 92 Credits 115 | |
|
Thank you very much for the explanation by Han Ye Gu Xing, which is very clear. Thank you again!!!
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |