Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrolling Text

Status
Not open for further replies.

anam711

Programmer
Apr 25, 2006
5
US
Folks,

I am trying to develope a speed-reading program for my own personal use.

I want the program to display a text file, character by character, from right to left in a single horizontal line on the screen. As characters appear on the right side, they disappear on the left.


Can anyone help?

Dan (anam711)
 
How big is your file? Will it all fit in memory? If it can, read in the file, strip off all newlines and go through from beginning to end displaying 80 chars at a time.
 
There are a number of possible approaches but I wonder if based on the speed you update the characters the display may tend to flicker if it is constantly updating the line.
If that happens there are a few things you can do to reduce it.
One is to limit the number of characters displayed into a fixed width box so the total amount of update to the screen is reduced. Another method may be creating a very wide div to contain a long string of text, putting another div on top to mask out all but one section and then repositioning the text div in increments behind the masking div so you are simply sliding the text window to the left at a given speed.

Try simpler approaches first and see how they work though.

Here is a bit of code to read the text file.
If you are executing your code on your own PC then you can use a local path to the text file you want to read. If you execute it on the server then you can use a relative path to the file on the server or you can use a full path to the file on a different server.
In my case I created the script on my desktop and put the text file in the same location then just specified the filename to load it.
Code:
<script type='text/javascript'>
<!--
function include(url) {
  if (document.all)  { // IE version
    try {
      var xml = new ActiveXObject("Microsoft.XMLHTTP");
      xml.Open( "GET", url, false );
      xml.Send()
      return xml.responseText;
    }
    catch (e) {
      var xml = new ActiveXObject("MSXML2.XMLHTTP.4.0");
      xml.Open( "GET", url, false );
      xml.Send()
      return xml.responseText;
    }
  }
  else { // Mozilla/Netscape 6+ version
    var xml=new XMLHttpRequest();
    xml.open("GET",url,false);
    xml.send(null);
    return xml.responseText;
  }
}
var myText = include('mytextfile.txt');
//-->
</script>


It's hard to think outside the box when I'm trapped in a cubicle.
 
Sorry, I am doing my program in VB6 and mistakenly posted to this (javascript) forum. I sincerely appreciate your replies.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top