Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does random not work in GUI in REBOL?

This very simple script:

REBOL []
view layout [
    button "Rand" [alert to-string random 100]
]

gives the following results:

  • 1-st run: 95, 52, 80, 96 ...
  • 2-nd run: 95, 52, 80, 96 ...
  • 3-rd run: 95, 52, 80, 96 ...

    ...

This is obviously not random because the same numbers repeat over and over again.

  • Should I issue a bug report to the REBOL website?
  • Is there a simple way to fix it?
like image 494
Caridorc Avatar asked Sep 19 '14 10:09

Caridorc


1 Answers

It sounds like you'd like to start with a different seed each time you run your script. Typically, the current time is used as a seed in these cases. This has nothing to do with whether you're using the GUI or not.

Try:

REBOL []
random/seed now/precise
view layout [
    button "Rand" [alert to-string random 100]
]
like image 180
WiseGenius Avatar answered Oct 05 '22 11:10

WiseGenius