#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' #''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' #''SCRIPT NAME: Select Random Name #'' #''SCRIPT CREATOR: Automated Testing Institute #'' #''SCRIPT OBJECTIVE: The objective of this script is to randomly generate a name #'' from a known array of names #''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' #''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' def GenerateRandomName() #Load libraries require 'win32ole' #Declare Variables - Note: No need to declare variables in Ruby #Get a collection of all list items (options objects) nameArray = ["John", "Becky", "Mike", "Sue", "Peter", "Linda", "John", "Mattie", "Frank", "Betty", "Timmy", "Ellen", "Lynwood", "Christine"] #Get a count of the total number of items in the collection nameCount = nameArray.length #Use random number generator to randomly select a list item index randomInt = rand(nameCount) return(nameArray[randomInt]) end #Test the function puts "The random name chosen from the list is: " + GenerateRandomName()