PowerBuilder
PowerBuilder
Generating Random ASCII Strings
See more PRNG Examples
Demonstrates how to generate random us-ascii strings.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Fortuna
integer li_BDigits
integer li_BLowercase
integer li_BUppercase
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 strings having only lowercase chars (a-z)
// Disallow digits and uppercase and only allow lowercase
li_BDigits = 0
li_BUppercase = 0
li_BLowercase = 1
Write-Debug "-- only lowercase alpha (a-z)"
for i = 1 to 10
// Generate 20-character strings.
Write-Debug loo_Fortuna.RandomString(20,li_BDigits,li_BLowercase,li_BUppercase)
next
// Allow both lowercase and uppercase alpha chars
li_BUppercase = 1
Write-Debug "-- lower and uppercase alpha (a-zA-Z)"
for i = 1 to 10
// Generate 20-character strings.
Write-Debug loo_Fortuna.RandomString(20,li_BDigits,li_BLowercase,li_BUppercase)
next
// Allow digits (0-9)
li_BDigits = 1
Write-Debug "-- digits and lower/uppercase alpha (0-9a-zA-Z)"
for i = 1 to 10
// Generate 20-character strings.
Write-Debug loo_Fortuna.RandomString(20,li_BDigits,li_BLowercase,li_BUppercase)
next
// Allow only digits (0-9)
li_BUppercase = 0
li_BLowercase = 0
Write-Debug "-- only digits (0-9)"
for i = 1 to 10
// Generate 20-character strings.
Write-Debug loo_Fortuna.RandomString(20,li_BDigits,li_BLowercase,li_BUppercase)
next
destroy loo_Fortuna