Pick a name and number from a database (list in code)

I want to make a program that chooses from a list of names and numbers (that I will enter manually) and I want the program to choose one of each randomly, and show a display dialog with the information that it choose randomly, thanks.


This should work if your text file is something like this:

set textFile to choose file
	set theDB to open for access textFile
	set theContents to read theDB
	display dialog some paragraph of theContents
	close access theDB
on error
		close access textFile
	end try
end try

I want to make not a set number with a name or a set name with a number, I want to list the numbers and the names and have the DB choose one of each randomly and “Display Dialog” it. Thanks

Also, another question, I want to make an app that will say something (I will program what it will say later) so leave a “say” function with filling text and I will change it later, and it will start at a certain time like: 10:45 AM, say something, and end at 10:55 AM and say something and say something and I want it to repeat that 9 times. Thanks for all the help.

Is that possible with the way you did it above??? Thanks

Ben(jammin) (lol)

Perhaps something like this

set myNameList to {"Bob", "Carol", "Ted", "Alice"}
set myNumberList to {11, 22, 33, 44}

--randomly re-order both lists in tandem
repeat with ii from 1 to count of myNameList
	set scrambled to SwapPairedItems(myNameList, myNumberList, ii, random number from 1 to count of myNameList)
	set myNameList to item 1 of scrambled
	set myNumberList to item 2 of scrambled
end repeat

-- display results
repeat with ii from 1 to count of myNameList
	display dialog (ii as text) & " name is " & item ii of myNameList ¬
		& linefeed ¬
		& (ii as text) & " number is " & item ii of myNumberList
end repeat

on SwapPairedItems(aList, bList, i, j)
	set temp to item i of aList
	set item i of aList to item j of aList
	set item j of aList to temp
	set temp to item i of bList
	set item i of bList to item j of bList
	set item j of bList to temp
	return {aList, bList}
end SwappairedItems

it worked!! thx…