Saved Bookmarks
| 1. |
Solve : THREE BIG QUESTIONS? |
|
Answer» I'm back!!! 3. The loop command, how exactly does it work (examples please). There is a for loop and a goto loop. The loops RETURN to a previous line of code and REPEATS the same lines of code with a DIFFERENT index value. Example: Code: [Select]echo off setlocal enabledelayedexpansion for /L %%i in (1,1,1000) do ( set /p variable=Enter: echo variable = !variable! echo To Quit, Enter: q if !variable!==q goto end ) :end echo ByeOutput: C:\batch> nevertest.bat Enter:one variable = one To Quit, Enter: q Enter:two variable = two To Quit, Enter: q Enter:7 variable = 7 To Quit, Enter: q Enter:q variable = q To Quit, Enter: q Bye C:\batch>2. functions Quote from: tommyroyall on March 16, 2010, 11:54:38 AM 1. How can I create a randomized number with parameters. C:\batch>TYPE ran.bat Code: [Select]echo off :ran echo random = %random% echo To quit enter q or c to continue set /p quit=Enter: if %quit%==q goto end goto ran :end Output: C:\batch> ran.bat random = 29071 To quit enter q or c to continue Enter:c random = 18757 To quit enter q or c to continue Enter:c random = 6542 To quit enter q or c to continue Enter:c random = 3041 To quit enter q or c to continue Enter:c random = 3856 To quit enter q or c to continue Enter:c random = 11257 To quit enter q or c to continue Enter:q C:\batch> reference: http://www.mathworks.com/access/helpdesk/help/toolbox/simevents/gs/a1076612075b1.html Quote from: tommyroyall on March 16, 2010, 11:54:38 AM 1. How can I create a randomized number with parameters. Code: [Select]echo off setLocal EnableDelayedExpansion for /L %%i in (1,1,%1 ) do echo random = !random! Output: C:\batch> ran2.bat 10 random = 5753 random = 1393 random = 5122 random = 16528 random = 12823 random = 14365 random = 5550 random = 28604 random = 1085 random = 11756 C:\batch> |
|