Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Random access strings in file

0 views
Skip to first unread message

par...@my-dejanews.com

unread,
Apr 22, 1999, 3:00:00 AM4/22/99
to
Hi,

This is a sch project .wonder any can help ?

i have a file that stores ten phrases.
How do i access each phrase in random ?


thanks

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

Thomas Matthews

unread,
Apr 22, 1999, 3:00:00 AM4/22/99
to

Read the strings into an array of strings. Count the number of phrases.
Generate a random array index between 0 or 1 and the number of strings. Use
this as an index into the array.

So, what language?

--
Thomas Matthews
email: mat...@stamps.stortek.com

Taswar Bhatti

unread,
Apr 22, 1999, 3:00:00 AM4/22/99
to

Why don't u read the phrase into an array and use a random number
generator to choose an index in the array.
Bye,
Taz

Irv Mullins

unread,
Apr 22, 1999, 3:00:00 AM4/22/99
to
par...@my-dejanews.com wrote:
>
> Hi,
>
> This is a sch project .wonder any can help ?
>
> i have a file that stores ten phrases.
> How do i access each phrase in random ?
>

atom fn
object phrase

fn = open("PHRASES.DAT","r")
for i = 1 to rand(10) do
phrase = gets(fn)
end for
puts(1,phrase)


Irv

Peter Shaggy Haywood

unread,
May 2, 1999, 3:00:00 AM5/2/99
to
Groovy hepcat par...@my-dejanews.com was jivin' on Thu, 22 Apr 1999
18:01:57 GMT in comp.programming.
Random access strings in file's a cool scene! Dig it!

>i have a file that stores ten phrases.

How are they stored? What format? Delimited how?

>How do i access each phrase in random ?

System? Language? Compiler/assembler/interpreter/whatever? We need
more information here, man.
--

----- Dig the EVEN NEWER, MORE IMPROVED news sig!! -----

-------------- Shaggy was here! ---------------
http://aardvark.apana.org.au/~phaywood/
============= Ain't I'm a dawg!! ==============


0 new messages