(PureBasic) Generating Random Integer in Range
Demonstrates how to generate random integers in a specified range.
IncludeFile "CkPrng.pb"
IncludeFile "CkGlobal.pb"
Procedure ChilkatExample()
; All Chilkat classes can be unlocked at once at the beginning of a program
; by calling UnlockBundle. It requires a Bundle unlock code.
chilkatGlob.i = CkGlobal::ckCreate()
If chilkatGlob.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i = CkGlobal::ckUnlockBundle(chilkatGlob,"Anything for 30-day trial.")
If success <> 1
Debug CkGlobal::ckLastErrorText(chilkatGlob)
CkGlobal::ckDispose(chilkatGlob)
ProcedureReturn
EndIf
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
CkGlobal::ckDispose(chilkatGlob)
CkPrng::ckDispose(fortuna)
ProcedureReturn
EndProcedure
|