Sample code for 30+ languages & platforms
DataFlex

Generating Random Integer in Range

See more PRNG Examples

Demonstrates how to generate random integers in a specified range.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoFortuna
    Integer i
    Integer iTemp1

    Move False To iSuccess

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

    Move False To iSuccess

    Get Create (RefClass(cComChilkatPrng)) To hoFortuna
    If (Not(IsComObjectCreated(hoFortuna))) Begin
        Send CreateComObject of hoFortuna
    End

    // Generate random integers between 12 and 24 inclusive

    For i From 0 To 100
        Get ComRandomInt Of hoFortuna 12 24 To iTemp1
        Showln iTemp1
    Loop



End_Procedure