DoctorD90

RRand.tcl 3.2.0

Jun 7th, 2012
229
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 0.95 KB | None | 0 0
  1. ### RRand.tcl 3.2.0 pQFrdM8L
  2.  
  3. #REQUIREMENTS
  4. # PBinScr.tcl fMrtKqyq
  5.  
  6. #LICENSE
  7. #Distribuited under License ___
  8.  
  9. #PATERNITY
  10. #Coder: DoctorD90
  11. #Network: irc.OnlineGamesNet.net
  12. #Chan: #eHito
  13. #
  14. #Thanks to guys on #egghelp on irc.freenode.net
  15.  
  16. #PURPOSE
  17. # With this proc, it'll be simplier randomize
  18. #a number in an interval between 2 of them
  19. # of your choice.
  20.  
  21. #USAGE
  22. #set var [rrand a b]
  23. #  a  InferiorLimit
  24. #  b  SuperiorLimit
  25.  
  26.  
  27. ### DON'T EDIT ANYTHING BELOW ###
  28.  
  29. proc rrand {inf sup} {
  30.   if {![string is integer -strict $inf]} {
  31.     error "Inferior Limit is not a number"
  32.   }
  33.   if {![string is integer -strict $sup]} {
  34.     error "Superior Limit is not a number"
  35.   }
  36.   if {$inf == $sup} {
  37.     return $inf
  38.   }
  39.   if {$inf > $sup} {
  40.     set infb $inf
  41.     set inf $sup
  42.     set sup $infb
  43.   }
  44.   set gap [expr {$sup - $inf + 1}]
  45.   return [expr {int(rand()*${gap})+${inf}}]
  46. }
  47.  
  48. putlog "RRand.tcl LOADED"
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment