Author Topic: Random Number Generator App  (Read 193 times)


  • Kindly Curmudgeon
  • Administrator
  • *****
  • Posts: 4228
Random Number Generator App
« on: March 27, 2018, 03:22:20 PM »
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.


« Last Edit: March 30, 2018, 08:28:25 AM by DrollTroll »
25 years with DesignCAD


  • Hero Member
  • *****
  • Posts: 1914
  • Intel i7-960, 12GB, NVidiaGTX570, Win7x64, DC26.2
    • World of van Vliet
Re: Random Number Generator App
« Reply #1 on: March 29, 2018, 07:47:28 PM »
And the Master has spoken again  ;D