VoiceGuide IVR Software Main Page
Jump to content

Random Number Generation

Recommended Posts

I've tried variations for obtaining a random number, but I always get the SAME number.

 

I.E. It'll give me a random number, BUT, each time I call and run the script I always get the SAME number.

 

Can someone help ??

 

 

Thanks

Share this post


Link to post

You will have to call the Randomize() function first..

 

Here is a demo VB Script which generates a random number between 0 and 999 (easy to modify for other ranges).

You can use in a "Run VBScript" module, after running that module you will be able to access the random value elsewhere in the script using the Result Variable $RV[Random].

 

Make sure to select the "Wait until VB Script Finishes" option, otherwise the result of the script will not be read in by VoiceGuide!

 

 

 

dim iRandomNumber, strResultVariables

 

Randomize()

iRandomNumber = Int((1000 * Rnd))

strResultVariables= "[Random]{" & iRandomNumber & "}"

iRet = WriteResultFile(strResultVariables)

 

 

function WriteResultFile(strResult)

const ForReading=1, ForWriting=2, ForAppending=8

Dim filename, fso, ts, outdata, outdata2, outdata3

 

filename = "VGRUNRESULT_$RV_DEVICEID.TXT"

set fso = CreateObject("Scripting.FileSystemObject")

set ts = fso.OpenTextFile(filename, ForWriting, True)

ts.WriteLine(strResult)

ts.Close

WriteResultFile = 0

end function

Share this post


Link to post

THANKS ! It worked very well.

 

Is there a way to use or run the VB script using the

older 2.9 version of voiceguide ??

 

Is there a way to generate RANDOM numbers using the 2.9 version of voiceguide ??

 

 

Thanks

Share this post


Link to post

With v2.9 you would need to run the vbscript using the WSCRIPT.EXE or CSCRIPT.EXE tools installed in Window's SYSTEM32 directory- calling them using the Run Program module.

 

You would need to modify the returned result.txt file to be of the format expected by v2.9:

 

The contents would be (example):

 

SUCCESSS

724

Share this post


Link to post

Is this VB script generate unique random number or repeated random number?

Would you please also teach me how to change VB scrip from 3 digits to 12 digits?

 

I need to generate the card number and the card number should be unique and 12 digit.

 

Thanks

Farzad

Share this post


Link to post

Just generate four 3 digit numbers and the concatenate them together (as strings) - then you'll get a 12 digit number (as a string).

 

NB. This is not really a VoiceGuide related question - I'd suggest speaking to your local programmers for non-VoiceGuide related questions instead of posting them on this forum...

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×