473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Reading files by line number

AaronL
99
Hello,

I am developing a fun TTS program and I've run into a bit of a problem.

Basically I am bringing in a list of sentences into a database and randomly selecting them, at the same time keeping a database of sentences that have already been used until all of them have been used and then it resets itself. The problem is, 1. I don't like loading these all into an array because of memory purposes. 2. I don't want to have a limitation on how many sentences I can use which is currently 1000 for memory sake. Any advice on this? Code is below

Expand|Select|Wrap|Line Numbers
  1. 'This is the randomizer for random phrases
  2.  
  3. 'If no phrases are found, exit.
  4. If RandCount <= 0 Then
  5.     Speak "I have nothing to say."
  6.     Exit Function
  7. End If
  8.  
  9. 'Resets the count if all phrases have been used.
  10. If LastCount > RandCount Then
  11.     For LastLoop = 1 To 1000
  12.         LastPhrase(LastLoop) = ""
  13.     Next LastLoop
  14.     LastCount = 1
  15. End If
  16.  
  17. 'Randomizes phrases and makes sure no repeats happen.
  18. RANDPHRASE:
  19.     Randomize
  20.     RandGen = Int(Rnd * RandCount + 1)
  21.     If RandGen = 0 Then GoTo RANDPHRASE
  22.     If RandCount > 10 Then
  23.         For LastLoop = 1 To 1000
  24.             If RandomPhrase(RandGen) = LastPhrase(LastLoop) Then
  25.                 GoTo RANDPHRASE
  26.             End If
  27.         Next LastLoop
  28.     End If
  29.     Speak RandomPhrase(RandGen)
  30.     RepeatPhrase = RandomPhrase(RandGen)
  31.     If RandCount > 10 And LastCount <= 1000 Then
  32.         LastPhrase(LastCount) = RandomPhrase(RandGen)
  33.     End If
  34.     LastCount = LastCount + 1
Dec 22 '07 #1
1 1084
Killer42
8,435 Expert 8TB
Sorry you don't seem to be getting any response to your question. What version of VB are you using?

In any case, perhaps the easiest thing would be to leave your sentences in the database, and just retrieve them one at a time. Your array need only hold the key value (or bookmark value, perhaps) for each sentence. This will make the memory usage much smaller.

By the way, how much RAM do you have? I wouldn't generally expect a few Mb to be much of an issue these days.
Dec 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Millennium Falcon | last post by:
Hi! Help is kindly requested in reading floating point numbers from a text file. File is organized like this : 2000 // number of data -1.00000 -2.000000 -0.008944 // x, y & z-coordinates to...
9
by: paczkow | last post by:
Dear Python Community, I am an engineering and I am experiencing some trouble. Having output data from other software I want to use it. To achieve this I decided to use Python since this...
15
by: leorulez | last post by:
Is there any way to read multiple files (more than 1000 files) and then write into one single output file using C? Right now in my program, I have a loop which asks for the filename and writes into...
2
by: Wes Peters | last post by:
Does anyone know of an article that deals with the subject of reading a structured text file using VBA code in Access? Thanks, Wes
2
by: sani8888 | last post by:
Hi everybody I am a beginner with C++ programming. And I need some help. How can I start with this program *********** The program is using a text file of information as the source of the...
10
by: Tyler | last post by:
Hello All: After trying to find an open source alternative to Matlab (or IDL), I am currently getting acquainted with Python and, in particular SciPy, NumPy, and Matplotlib. While I await the...
1
by: akalmand | last post by:
Hi there, I am writing a code to read some data from the text files. The number of text files is not fixed and could be more that 15. the length of each file is large... close to 100,000 on an...
10
by: lancer6238 | last post by:
Hi all, I'm having programs reading from files. I have a text file "files.txt" that contains the names of the files to be opened, i.e. the contents of files.txt are Homo_sapiens.fa...
3
by: Pinux | last post by:
Hi, I am writing a multi-threads encryption application. The idea of the code is to create a number of threads to encrypt files. I have a thread pool say the maximum threads is 10. If the number...
2
by: rka77 | last post by:
Hi, I am trying to make a Python2.6 script on a Win32 that will read all the text files stored in a directory and print only the lines containing actual data. A sample file - Set : 1 Date:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.