DesignCAD SDK > User Contributions

Random Number Generator App


DesignCAD doesn't currently have a function to generate random numbers. Attached is a zip file containing a simple console program that will generate as many pseudorandom numbers as you like (on the range of 0 to 1.0) , and store them in a text file.

Syntax: dc_random.exe count outfile
where count indicates how many numbers to generate, and outfile is the name of the text file in which the numbers are stored.

For example: dc_random 100 c:\DesignCAD\100randomnums.txt  will generate a file named 100randomnums.txt in the folder C:\DesignCAD; the file will contain 100 random floating-point numbers between 0 and 1.

If the count value is omitted, the default value is 100. If the outfile argument is omitted, the file name is dc_random.txt, and is stored in the same folder as the dc_random program. If the path portion of the filename is omitted, the output file will (probably) go into the same folder as the dc_random program, but this may vary depending on how the program is run.

The zip file also contains a sample macro randomnums.d3m that runs the program, generates 100 random numbers, and plots them as y values (with x being the index of the input number). Note that there is no way to guarantee that the program will finish before the macro tries to open the file, so this may not work with a very large sequence of numbers; in such cases, it is best to generate the text file separately.



And the Master has spoken again  ;D



[0] Message Index

Go to full version