• Print

Author Topic: Casual 1.0  (Read 318 times)

VictorX

  • Newbie
  • *
  • Posts: 25
  • Never give up!!!
    • Email
Casual 1.0
« on: November 13, 2012, 12:28:30 PM »
This is a continuation of this topic: http://www.qb64.net/forum/index.php?topic=7373.0

I have written a very simple library, Casual.li, that allows you to get a random number from 0 to 0.999999.
The difference between my library and the RND statement is that when you restart your program it doesn't repeat the same sequence of numbers.

To use it, of course you have to include it in your program, and then you have to use the GETNUMBER function.

Here is an example:
Code: [Select]
FOR i = 1 TO 5
    LOCATE i, 1: PRINT GETNUMBER
    LOCATE i, 15: PRINT INT(GETNUMBER * 6) + 1
NEXT i
'$INCLUDE:'.\casual.li'
VictorX

Clippy

  • Hero Member
  • *****
  • Posts: 16440
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: Casual 1.0
« Reply #1 on: November 13, 2012, 01:42:14 PM »
You can achieve similar results using TIMER. TIMER returns the number of seconds in a day and differs every second.

RANDOMIZE TIMER
« Last Edit: November 13, 2012, 11:40:18 PM by Clippy »
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2264
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: Casual 1.0
« Reply #2 on: November 13, 2012, 04:26:12 PM »
Yes, what Clippy said works just as well.

RANDOMIZE TIMER
PRINT INT(RND(1) * 6) + 1

  • Print