HumanZoo22 Posted January 16, 2008 Share Posted January 16, 2008 Hello;I was woundering if there is any kind of programming language that i could be able to build a text scroller that loads the words a little at a time, becuase the text file im trying to put on my site is 4 megabitesthanks - Levi Link to comment Share on other sites More sharing options...
justsomeguy Posted January 16, 2008 Share Posted January 16, 2008 You might be able to use some AJAX to get pieces of the text from a PHP script, but PHP will read the entire file in at once. It will be using the server's memory though, not the client's, but if you have a lot of people using the site at once that's going to take a lot of memory on the server to have 4MB of text in memory for each user on the site.Incidentally, if you're trying to show 4 million characters there might be a better way then a scrolling line. Link to comment Share on other sites More sharing options...
Synook Posted January 17, 2008 Share Posted January 17, 2008 What in the world does the 4 MB text file contain? And can it be split? Link to comment Share on other sites More sharing options...
jeffman Posted January 23, 2008 Share Posted January 23, 2008 This may be too little, too late, but I needed the mental diversion. I was woundering if there is any kind of programming language that i could be able to build a text scroller that loads the words a little at a time, becuase the text file im trying to put on my site is 4 megabitesAny SS language. I'll outline the method and you can think of the code. I know I could do this in perl with just a few lines. What follows assumes that you really don't need a var in your script that holds 4 meg. You didn't say so, but by scrolling, I assume you mean the data can be trashed once it scrolls out of site. Anyway . . .Your browser script (client) starts with a variable that stores a character index, initialized to 0.Via AJAX, the client asks the server for the next highest character (or more likely a bufferload of characters: 256, 1024, whatever).When the server app gets called, it opens the correct file and reads ONLY from the index and ONLY the number of chars that were requested. Then it returns the data. This call will execute FAST.The client receives the data and updates the index var by the number of chars it received. Then it does the display routine.Repeat while the buffer is full.When your SS app gets an EOF or undefined value, it stops reading. So it sends your client fewer chars than the client expects, terminated by an EOF or just nothing, your preference.The client registers the condition and does its display thing. If it wants scroll forever, it sets the index var to 0 and starts over. If not, it just quits.No need for any temporary storage file.If you want to be kind to your ISP, you might find out how big the server's internal read buffer is and set yours to the same size. But don't bother if you only expect a dozen visitors a day. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.