![]() |
RND batch file example
Hello, Could some one please help me out and post an example Randomize function in batch? One that produces random text or numbers like the RND lib function in VB.
Thanks in advance. cueballr. =] |
Re: RND batch file example
Why not just write a small program, in whatever language, that generates random numbers and/or text, and then call it from the batch file? You also never said how you want the numbers/text. Are you wanting them to be displayed on the screen? This is quite simple. Do you want to use the output of the program as input into another program? This is also petty simple, as the program itself will be the same, but you will use pipes in the batch file. Do you want something else entirely? Your post was pretty vague, so you'll either need to give more information, or ask a psychic person for assistance.
|
Re: RND batch file example
If i would have wanted to call a VB RND program i would have done so, but i want an example in batch code, and no i dont want to use the out put as the input of another program, i simply want to use the function to name temp files, or anything else for that matter.Assistance would be apreciated.
thanks in advance. cueballr. =] |
Re: RND batch file example
Whether or not your particular shell/batch facility has a randomize feature depends on your system and any utilities that have been added. Generally, you will find you need to invoke another program (and use redirection, temp files, etc.), whether it was written by you or someone else.
The response you got was perfectly sensible. Perhaps you'd prefer Google? |
Re: RND batch file example
I googled it before i made the first post and found an example, but it was not the type i needed, also it flashed an error while running the script, i just wanted another one.:)
If someone could point out the error in that script it would be appreciated. :
@ECHO OFFthe error flashed while running the above is "Invalid Parameter to SHIFT command" and FYI it does write the file "rresult.txt", but its the same data written into the file everytime, and if im not mistaken thats not what it should be doing. any help would be nice. =] thanks. cueballr. =] |
Re: RND batch file example
This doesn't make any sense:
FOR %%v IN (SET SHIFT GOTO:Loop1) DO %%v R%2=%3That's going to try to generate some like: :
SET R1=1 |
Re: RND batch file example
Could you suggest a fix to that code?, is that possibly why it always writes "13" to the "rresult.txt" file?:-/
|
Re: RND batch file example
It turns out that command extensions are on by default, so the SHIFT with a parameter will definitely fail.
Explain what you're trying to accomplish, and what parameters you will be passing and what they're for. Your original post asks for a random number and doesn't explain your goal. Your script seems to be wanting to use TIME for random generation. Given the output of TIME, it seems like a relatively poor choice for anything but the ugliest generation of a variable file name. |
Re: RND batch file example
Quote:
tmpnam() in C/C++. |
| All times are GMT -5. The time now is 9:08 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC