Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32279
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2017-01-23 12:28 -0800 |
| References | (5 earlier) <8faaf70c-8e7b-4dc5-a023-9ce2d2996c2c@googlegroups.com> <931577e5-a727-4243-99af-d0b436760cc8@googlegroups.com> <2fd047d8-bee3-4192-8c4a-799c84d6876c@googlegroups.com> <fb96a259-8a1b-4202-b615-3ef6fed59ac7@googlegroups.com> <4d6a078b-9944-4244-8fb6-d5b23ed42635@googlegroups.com> |
| Message-ID | <6ca890bf-4f64-41f7-9ec6-2f69b6db7e91@googlegroups.com> (permalink) |
| Subject | Re: Read in file to array. |
| From | jonas.thornvall@gmail.com |
Den måndag 23 januari 2017 kl. 20:39:06 UTC+1 skrev jonas.t...@gmail.com:
> Den måndag 23 januari 2017 kl. 20:24:35 UTC+1 skrev jonas.t...@gmail.com:
> > Den måndag 23 januari 2017 kl. 19:29:54 UTC+1 skrev Michael Haufe (TNO):
> > > jonas.t...@gmail.com wrote:
> > >
> > > > [... code ...]
> > >
> > > copy and paste your JavaScript into here and fix the problems you see:
> > >
> > > <http://jshint.com/>
> >
> > Well i think i can see what is going on but i just don't understand the inline functions within functions.
> > What i probably wan't is to make textFromFileLoaded visible outside the {} paragraphs, but i am a bit lost i really do not understand this code.
> >
> > I find it strange though that i can not define a global variable mytext and copy textFromFileLoaded to it? And why does it work the second time.
> >
> > fileReader.onload = function(fileLoadedEvent)
> > {
> > textFromFileLoaded = fileLoadedEvent.target.result;
> > document.debug.data.value = textFromFileLoaded;
> > mytext=textFromFileLoaded;
> >
> > };
>
> But the good part load graph works i just have to push load button two times ;)
function loadGraph()
{
var fileToLoad = document.getElementById("fileToLoad").files[0];
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var textFromFileLoaded = fileLoadedEvent.target.result;
document.debug.data.value = textFromFileLoaded;
mytext=textFromFileLoaded;
};
fileReader.readAsText(fileToLoad, "UTF-8");
//alert(mytext);
var sub=mytext.split("!");
for (var m = 0; m <sub.length ; m ++ )
{
arr[m] ={nodelinks : [], hold : false, rposX : 0, rposY : 0, rwidth : 10, rheigth : 10, rcolor : "red" , bcolor : "green"};
}
var x=0;
while (x<sub.length){
var dataitem=[];
dataitem=sub[x].split("*");
//alert(sub[x]);
var a=0;
while(a<dataitem.length){
var links=dataitem[1].split(",");
var b=0;
while (b<links.length) {
arr[x].nodelinks[b]=parseInt(links[b]);
b++;
}
arr[x].hold=false;
arr[x].rposX=parseInt(dataitem[3]);
arr[x].rposY=parseInt(dataitem[4]);
arr[x].rwidth=parseInt(dataitem[5]);
arr[x].rheigth=parseInt(dataitem[6]);
arr[x].rcolor=dataitem[7];
arr[x].bcolor=dataitem[8];
a++;
}
x++;
}
texten="";
for (var m = 0; m < sub.length; m ++ ) {
texten+=m+"*"+arr[m].nodelinks+"*"+arr[m].hold+"*"+arr[m].rposX+"*"+arr[m].rposY+"*"+arr[m].rwidth+"*"+arr[m].rheigth+"*"+arr[m].rcolor+"*"+arr[m].bcolor+"!";
}
document.debugtwo.datatwo.value = texten;
}
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 03:29 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 03:59 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 06:26 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 07:41 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 08:08 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 08:43 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 09:41 -0800
Re: Read in file to array. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-23 10:29 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 11:24 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 11:38 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 11:56 -0800
Re: Read in file to array. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-23 20:36 +0000
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 19:54 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 20:10 -0800
Re: Read in file to array. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-24 14:27 +0000
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-24 08:24 -0800
Re: Read in file to array. Jake Jarvis <pig_in_shoes@yahoo.com> - 2017-01-24 17:42 +0100
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-24 08:54 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-24 09:04 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-24 11:07 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-24 13:17 -0800
Re: Read in file to array. Tim Streater <timstreater@greenbee.net> - 2017-01-24 21:35 +0000
Re: Read in file to array. Jake Jarvis <pig_in_shoes@yahoo.com> - 2017-01-24 22:42 +0100
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-24 15:32 -0800
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-24 15:55 -0800
Re: Read in file to array. Tim Streater <timstreater@greenbee.net> - 2017-01-25 08:59 +0000
Re: Read in file to array. Jake Jarvis <pig_in_shoes@yahoo.com> - 2017-01-25 01:58 +0100
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-24 18:51 -0800
Re: Read in file to array. Jake Jarvis <pig_in_shoes@yahoo.com> - 2017-01-25 10:29 +0100
Re: Read in file to array. Tim Streater <timstreater@greenbee.net> - 2017-01-25 08:58 +0000
Re: Read in file to array. jonas.thornvall@gmail.com - 2017-01-23 12:28 -0800
Re: Read in file to array. Tim Streater <timstreater@greenbee.net> - 2017-01-24 17:21 +0000
csiph-web