10-17-2019 10:26 AM
Hi all,
I just noticed something weird. Is it me or is it System Exec.vi?
Now call the same .bat from System Exec.vi in LabVIEW. The random numbers returned are not random; they increment by 3 every second.
What could be causing this? I suspect that System Exec.vi is using some odd form of system time when it generates its random numbers and that this form is different to the one that cmd line uses.
Any help or advice is welcome!
Max
10-17-2019 10:48 AM
https://devblogs.microsoft.com/oldnewthing/20100617-00/?p=13673
10-17-2019 11:11 AM
Ok, thanks for the link.
I think I have figured it out: When I open the cmd window, the random number generator is seeded with the system time. When I call %RANDOM% the first time, the result is not random, it is seeded with the system time. Subsequent calls of %RANDOM% in the same cmd window are then pseudo random, so %RANDOM% is not reseeded.
When I make a call to system exec.vi, it is like opening a new cmd window, which results in reseeding of the generator and non-random output. To get a pseudo random output from my bat file using system exec.vi I need to ignore the first return from %RANDOM%.