Sample code for 30+ languages & platforms
PowerBuilder

Generating Random Integer in Range

See more PRNG Examples

Demonstrates how to generate random integers in a specified range.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Fortuna
integer i

li_Success = 0

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

li_Success = 0

loo_Fortuna = create oleobject
li_rc = loo_Fortuna.ConnectToNewObject("Chilkat.Prng")
if li_rc < 0 then
    destroy loo_Fortuna
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Generate random integers between 12 and 24 inclusive

for i = 0 to 100
    Write-Debug string(loo_Fortuna.RandomInt(12,24))
next


destroy loo_Fortuna