|
Register | Blogging | Today's Posts | Search |
|
Thread Tools | Display Modes |
![]() |
#1 (permalink) |
Juicious Maximus III
Join Date: Nov 2008
Location: Scabb Island
Posts: 6,525
|
![]()
Okay, okay - I realize I probably couldn't have made a more nerdy thread and I guess it's doomed to die an embarassing death, but I was wondering, have or do anyone else here do any batch programming?
![]() Yes, it's pretty weak as far as programming go and yes, there's not much you can do with it but I used to play around with it as a kid (started with fiddling around in the autoexec.bat) and so I picked it up again a couple of years ago to see if I could do something interesting with it. Once I got my imagination going, it seems I could. The very easiest though perhaps not the most useful thing I wrote was this little thing which generates a random number between 1 and whatever value you want. Code:
@echo off if "%1"=="" goto missing if "%1"=="?" goto missing if "%1"=="/?" goto missing :random set /a trandom=(%random%*%1/32768)+1 goto result :missing echo. echo This file generates random numbers from 1 to the number you define. echo. echo To define a number, as an example - just write like this : "tdrandom 6". echo That gives you a random number between 1 and 6. echo. echo You can edit this file and remove the last line if you want to keep echo the random variable in the memory for use with other files. echo. echo -- Tore goto end :result echo. echo Result = %trandom% :end set trandom= For windows people, if you want to try it, just copy and paste this into a text file, save it as whatever.bat (changing the filetype to "bat" rather than "txt")and then click the start menu, choose run and write "cmd" in the box and press enter. You will open the command prompt. Navigate to where the file is and write the filename, that will run it. This is of course the simplest thing I did, I've advanced beyond this and I found that there are some charming features to this old batch stuff. I especially like the way you can do for-loops (I can post examples later on)! So, anyone else here who have fiddled around with this ancient art? :p
__________________
Something Completely Different |
![]() |
![]() |
|