All you need to do is pick a random number between 1 and 3, then read that many sets of items - the last set read will be the one you want.
restore CARS
read CarCount
Item = rnd(CarCount-1)+1
for i = 1 to Item
read CarName$
read x, y, z
next
print CarName$
print x
print y
print z
sync off
wait key
end
CARS:
DATA 3
DATA "Car", 100, 10, 10
DATA "Bus", 60, 5, 15
DATA "Race Car", 150, 25, 2
Another way to do this would be to put the items into an array first to save reading through the items - you'll get a big speed gain that way when accessing items in a large list.
type Cars_t
Name as string
x
y
z
endtype
restore CARS
read CarCount
dim CarList( CarCount ) as Cars_t
for i = 1 to CarCount
read CarList(i).Name
read CarList(i).x
read CarList(i).y
read CarList(i).z
next
Item = rnd(CarCount-1)+1
print CarList(Item).Name
print CarList(Item).x
print CarList(Item).y
print CarList(Item).z
sync off
wait key
end
CARS:
DATA 3
DATA "Car", 100, 10, 10
DATA "Bus", 60, 5, 15
DATA "Race Car", 150, 25, 2
A little more code, but the array will be ready for immediate use every time you need it