PureBasic
PureBasic
Generating Random Integer in Range
See more PRNG Examples
Demonstrates how to generate random integers in a specified range.Chilkat PureBasic Downloads
IncludeFile "CkPrng.pb"
Procedure ChilkatExample()
success.i = 0
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
success = 0
fortuna.i = CkPrng::ckCreate()
If fortuna.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Generate random integers between 12 and 24 inclusive
i.i
For i = 0 To 100
Debug Str(CkPrng::ckRandomInt(fortuna,12,24))
Next
CkPrng::ckDispose(fortuna)
ProcedureReturn
EndProcedure