Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #34638

Re: DATA Structure one last time

Newsgroups comp.lang.javascript
Date 2018-01-23 01:22 -0800
References (5 earlier) <f63278fa-0cd4-4681-96b9-455d520f4c6a@googlegroups.com> <86gb6ddabbi3aga2609e2need5absic73r@4ax.com> <380d7510-683d-420c-9564-095c04ebcce5@googlegroups.com> <kd4c6d5tpnnuotlbfei2ivckpo2v4oeio2@4ax.com> <d37e2907-043f-4089-86e8-bf4e0e2c7338@googlegroups.com>
Message-ID <89614a3e-67bf-4d8d-9d02-8f03687b8d79@googlegroups.com> (permalink)
Subject Re: DATA Structure one last time
From Jonas Thörnvall <jonas.thornvall@gmail.com>

Show all headers | View raw


Den tisdag 23 januari 2018 kl. 06:36:34 UTC+1 skrev Jonas Thörnvall:
> Den måndag 22 januari 2018 kl. 17:32:41 UTC+1 skrev John G Harris:
> > On Mon, 22 Jan 2018 04:32:00 -0800 (PST), Jonas Thörnvall
> > <jonas.thornvall@gmail.com> wrote:
> > 
> >   <snip>
> > >The syntax "it is always the syntax" 
> > >
> > >And honestly i can not see any reason why 
> > >
> > >track[m].midiMess[n].time=whatever 
> > >
> > >Would be equivalent to push "assign a value to object [n] because ones it created that is how you can assign it a new value.
> > 
> >   track[m].midiMess
> > is an array object.
> > 
> >   track[m].midiMess[n]
> > is an element of that array. 
> > 
> > IF you have put a message object into that element, by doing something
> > like
> >   track[m].midiMess[n] = { /*a message object*/ };
> > then 
> >   track[m].midiMess[n].time
> > is a property of that message object. You can read from and write to
> > it.
> > 
> > BUT if you have never put anything into that element then the element
> > doesn't have properties (it's not an object; it's undefined).
> > 
> > 
> > You don't have to use push. You could do it the old-fashioned way :
> >   var size = track[m].midiMess.length;
> >   track[m].midiMess[size+1] = { /*Object you want to add*/ };
> > That's all that push does.
> 
> So track[m].midiMess[n] would have worked afterall, fuck now i get even more tired.
> So it was just the curly paragraphs missing, fuck you people really evil LoL
> No i mean it you are evil, anal anal retentive.
>  
> > 
> > >I probably should do it in a more object oriented way set all the properties at once and not one at a time, but yet again i do not know the syntax.
> > 
> > "all the properties at once"! There's thousands of them, you said.
> > 
> > >I could guess 
> > >track[m].midiMess[n]={time=clock,data0=mess0,data1=mess1,data2=mess2};
> > >Is that correct or I should probably use colons?
> > >But again it is not easy to guess the syntax to assign a subarray values, because that is what one do when one can not find appropriate examples.
> > 
> >   track[m].midiMess[n]
> >   = {time:clock, data0:mess0, data1:mess1, data2:mess2};
> > 
> > An appropriate example :
> > 
> >   var arr = [];  // An empty array
> >     // ...
> >   arr[5] = {first:"alpha", second:"beta"};  
> >     // Element 5 now holds an object
> > 
> >   John
> 
> Thank's John great Job!!! I think i save it until i forget the syntax next time.
> There is teacher material in you, for sure!!!
> 
> Don't mind about my comments, they are more a sign of my shortcomings then yours.

I've adjusted the program to the new structure. And now i am onto downmix tracks  "to an omni track zero" And i do it the old fashioned way reading over the element values from one array object to track zero. One track at a time and then sort track zero.

But of course if javascript offer to copy the track right of, to track zero that would be preferable and i read about assign.

Example assign i found.
const object1 = {
  a: 1,
  b: 2,
  c: 3
};
const object2 = Object.assign({}, object1);
console.log(object2.c);
// expected output: 3

The examples always the simplest general case so it is so hard to see if they apply.

And i guess since my tracks object is an array, if i try to merge many tracks downto one they will simply overwrite eachother, or? 

const allRules = Object.assign({}, obj1, obj2, obj3, etc);
If those were tracks, would they not write overeachothers indexes?

I would like the tracks stacked one after eachother,"and then i can do my midiMess.sort()" but is that possible?

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 01:50 -0800
  Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 02:09 -0800
    Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 03:35 -0800
      Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 04:10 -0800
        Re: DATA Structure one last time John G Harris <niam@jghnorth.org.uk.invalid> - 2018-01-21 18:04 +0000
          Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 20:03 -0800
            Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 20:07 -0800
            Re: DATA Structure one last time John G Harris <niam@jghnorth.org.uk.invalid> - 2018-01-22 10:47 +0000
              Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-22 04:32 -0800
                Re: DATA Structure one last time John G Harris <niam@jghnorth.org.uk.invalid> - 2018-01-22 16:32 +0000
                Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-22 21:36 -0800
                Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-23 01:22 -0800
                Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-23 05:18 -0800
                Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-23 05:38 -0800
                Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-23 05:44 -0800
                Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-23 06:07 -0800

csiph-web