Help Wanted

Blitz Basic. Read random line of text + wrap text – !ßrendan

!ßrendan

Member

Posts: 21
From: Western Australia
Registered: 07-04-2002
SeedRnd(MilliSecs())
random=Rnd(100)

file=ReadFile("data.txt")

Then line$=ReadLine( file )

Print line$
MouseWait
End

-----------------------------

OK, so far I've got this far, now here is the problem.
The random number generator picks a number between 1-100.
I have a text file with 100 lines (data.txt). Now I want
to read one of the 100 lines according to the random
number chosen. Then print the line.

2 problems

1. Reading one of the 100 lines according to the random
number. I don't know how to code this.

data=ReadFile("data.txt")
Then line$=ReadLine [?LineNumber=random?] ( data )

2. I need to wrap the text when it gets to the edge of the
display, and without cutting the words up.

------------------
-{!ßrendan}-

!ßrendan

Member

Posts: 21
From: Western Australia
Registered: 07-04-2002
*.bb
-------------------------
SeedRnd(MilliSecs())
number=Rnd(2)

file=ReadFile("data.txt")
SeekFile (file, number)
Print ReadLine$( file )

Print number
MouseWait
End
-------------------------
data.txt
-------------------------
line1
line2
line3
-------------------------

I've made some progress, so far this is my blitz basic code, and my data file.

The problem I have is in this section of code.

SeekFile (file, number)

I want the random number to represent a line (e.g. 0=line1,1=line2,2=line3)
But the SeekFile command uses the random number to move to a corresponding byte, not a different line.

eg.

012
line1

0=line1
1=ine1
2=ne1

If you copy the code and create the data file you can get a better view of what I'm trying to say... I you can help it would be awesome!

------------------
-{!ßrendan}-