Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #34613 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2018-01-21 01:50 -0800 |
| Last post | 2018-01-23 06:07 -0800 |
| Articles | 16 — 2 participants |
Back to article view | Back to comp.lang.javascript
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
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-21 01:50 -0800 |
| Subject | DATA Structure one last time |
| Message-ID | <7fc77627-cbc4-4427-83f7-74dc5e8b0123@googlegroups.com> |
function newTrack(m) {
track[m] ={
outport:[],
portname : [],
midichannel:[],
program:[],
midiMess:[{time:0,data0:0,data1:0,data2:0}]
};
return track;
}
function makeTrack() {
for (var m = 0; m < 101; m ++ ){
newTrack(m);
}
makeMidiMessages();
}
function makeMidiMessages(){
for (var m = 0; m<101; m++) {
for (var n=0;n<10000;n++){
track[m].midiMess[n];
}
}
//HOW CAN POSSIBLY THIS LINE PASS???????????????
track[0].midiMess[0].time=100;
//BUT NOT THIS ONE????????????????????????
track[0].midiMess[1].time=100;
console.log(track[0].midiMess[0].time);
}
[toc] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-21 02:09 -0800 |
| Message-ID | <a111ab7e-9e84-419f-af37-cb227a23a66d@googlegroups.com> |
| In reply to | #34613 |
Den söndag 21 januari 2018 kl. 10:50:48 UTC+1 skrev Jonas Thörnvall:
> function newTrack(m) {
> track[m] ={
> outport:[],
> portname : [],
> midichannel:[],
> program:[],
> midiMess:[{time:0,data0:0,data1:0,data2:0}]
> };
> return track;
> }
>
> function makeTrack() {
> for (var m = 0; m < 101; m ++ ){
> newTrack(m);
> }
>
> makeMidiMessages();
> }
>
> function makeMidiMessages(){
> for (var m = 0; m<101; m++) {
> for (var n=0;n<10000;n++){
> track[m].midiMess[n];
> }
> }
> //HOW CAN POSSIBLY THIS LINE PASS???????????????
> track[0].midiMess[0].time=100;
> //BUT NOT THIS ONE????????????????????????
> track[0].midiMess[1].time=100;
> console.log(track[0].midiMess[0].time);
> }
It is strange things like this that make me suspect i do not understand what the syntax of the structure i create mean.
I thought i have an array track that have another array midiMess as property. And that the midimess array also has properties that is why an assign like this should work. Once you created tracks and midimessages, but that is not the case.
So is it all misunderstood?
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-21 03:35 -0800 |
| Message-ID | <b8a8ec79-ae86-40ad-bc90-aec2a72af2c8@googlegroups.com> |
| In reply to | #34614 |
Den söndag 21 januari 2018 kl. 11:09:44 UTC+1 skrev Jonas Thörnvall:
> Den söndag 21 januari 2018 kl. 10:50:48 UTC+1 skrev Jonas Thörnvall:
> > function newTrack(m) {
> > track[m] ={
> > outport:[],
> > portname : [],
> > midichannel:[],
> > program:[],
> > midiMess:[{time:0,data0:0,data1:0,data2:0}]
> > };
> > return track;
> > }
> >
> > function makeTrack() {
> > for (var m = 0; m < 101; m ++ ){
> > newTrack(m);
> > }
> >
> > makeMidiMessages();
> > }
> >
> > function makeMidiMessages(){
> > for (var m = 0; m<101; m++) {
> > for (var n=0;n<10000;n++){
> > track[m].midiMess[n];
> > }
> > }
> > //HOW CAN POSSIBLY THIS LINE PASS???????????????
> > track[0].midiMess[0].time=100;
> > //BUT NOT THIS ONE????????????????????????
> > track[0].midiMess[1].time=100;
> > console.log(track[0].midiMess[0].time);
> > }
>
> It is strange things like this that make me suspect i do not understand what the syntax of the structure i create mean.
>
>
>
> I thought i have an array track that have another array midiMess as property. And that the midimess array also has properties that is why an assign like this should work. Once you created tracks and midimessages, but that is not the case.
>
> So is it all misunderstood?
Well i see now why i can access the first, it is created each time is created in the template "prototype".
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-21 04:10 -0800 |
| Message-ID | <7532beec-4167-49b2-bbad-28920c4d4058@googlegroups.com> |
| In reply to | #34615 |
Den söndag 21 januari 2018 kl. 12:35:25 UTC+1 skrev Jonas Thörnvall:
> Den söndag 21 januari 2018 kl. 11:09:44 UTC+1 skrev Jonas Thörnvall:
> > Den söndag 21 januari 2018 kl. 10:50:48 UTC+1 skrev Jonas Thörnvall:
> > > function newTrack(m) {
> > > track[m] ={
> > > outport:[],
> > > portname : [],
> > > midichannel:[],
> > > program:[],
> > > midiMess:[{time:0,data0:0,data1:0,data2:0}]
> > > };
> > > return track;
> > > }
> > >
> > > function makeTrack() {
> > > for (var m = 0; m < 101; m ++ ){
> > > newTrack(m);
> > > }
> > >
> > > makeMidiMessages();
> > > }
> > >
> > > function makeMidiMessages(){
> > > for (var m = 0; m<101; m++) {
> > > for (var n=0;n<10000;n++){
> > > track[m].midiMess[n];
> > > }
> > > }
> > > //HOW CAN POSSIBLY THIS LINE PASS???????????????
> > > track[0].midiMess[0].time=100;
> > > //BUT NOT THIS ONE????????????????????????
> > > track[0].midiMess[1].time=100;
> > > console.log(track[0].midiMess[0].time);
> > > }
> >
> > It is strange things like this that make me suspect i do not understand what the syntax of the structure i create mean.
> >
> >
> >
> > I thought i have an array track that have another array midiMess as property. And that the midimess array also has properties that is why an assign like this should work. Once you created tracks and midimessages, but that is not the case.
> >
> > So is it all misunderstood?
>
> Well i see now why i can access the first, it is created each time is created in the template "prototype".
Could not one of you analprobing monkeys told me that the syntax was.
track[m].midiMess.push({time:0,data0:0,data1:0,data2:0});
Fuck you make me tired.
[toc] | [prev] | [next] | [standalone]
| From | John G Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2018-01-21 18:04 +0000 |
| Message-ID | <kgl96dda6o6b8kn4j6ut7fj14i4ot7eklq@4ax.com> |
| In reply to | #34616 |
On Sun, 21 Jan 2018 04:10:05 -0800 (PST), Jonas Thörnvall
<jonas.thornvall@gmail.com> wrote:
// Add another blank message to the track's midi messages
> track[m].midiMess.push({time:0,data0:0,data1:0,data2:0});
I don't remember you saying you wanted to add another object to an
array. You just complained that you didn't know how to do it.
>Fuck you make me tired.
Yes, that's the way to get help.
John
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-21 20:03 -0800 |
| Message-ID | <f63278fa-0cd4-4681-96b9-455d520f4c6a@googlegroups.com> |
| In reply to | #34620 |
Den söndag 21 januari 2018 kl. 19:05:04 UTC+1 skrev John G Harris:
> On Sun, 21 Jan 2018 04:10:05 -0800 (PST), Jonas Thörnvall
> <jonas.thornvall@gmail.com> wrote:
>
> // Add another blank message to the track's midi messages
> > track[m].midiMess.push({time:0,data0:0,data1:0,data2:0});
>
> I don't remember you saying you wanted to add another object to an
> array. You just complained that you didn't know how to do it.
>
>
> >Fuck you make me tired.
>
> Yes, that's the way to get help.
>
> John
Well i showed you the structure didn't I?
And i asked you howto create a midiMess didn't I?
If you are a bit clueless of javascript syntax like me, then it ain't going to pop out of your brain by lookin at the structure, howto create a midiMess for that structure?
And why you call track an array, isn't it an object? If so what does that make midiMess a subobject? How can you say midiMess is an object and not track?
track[m].midiMess.push({time:0,data0:0,data1:0,data2:0});
function newTrack(m) {
track[m] ={
outport:[],
portname : [],
midichannel:[],
program:[],
midiMess:[{time:0,data0:0,data1:0,data2:0}]
};
return track;
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-21 20:07 -0800 |
| Message-ID | <c81c8eb4-4b71-4c4c-b894-54a502ee4317@googlegroups.com> |
| In reply to | #34625 |
Den måndag 22 januari 2018 kl. 05:04:00 UTC+1 skrev Jonas Thörnvall:
> Den söndag 21 januari 2018 kl. 19:05:04 UTC+1 skrev John G Harris:
> > On Sun, 21 Jan 2018 04:10:05 -0800 (PST), Jonas Thörnvall
> > <jonas.thornvall@gmail.com> wrote:
> >
> > // Add another blank message to the track's midi messages
> > > track[m].midiMess.push({time:0,data0:0,data1:0,data2:0});
> >
> > I don't remember you saying you wanted to add another object to an
> > array. You just complained that you didn't know how to do it.
> >
> >
> > >Fuck you make me tired.
> >
> > Yes, that's the way to get help.
> >
> > John
>
> Well i showed you the structure didn't I?
> And i asked you howto create a midiMess didn't I?
> If you are a bit clueless of javascript syntax like me, then it ain't going to pop out of your brain by lookin at the structure, howto create a midiMess for that structure?
>
> And why you call track an array, isn't it an object? If so what does that make midiMess a subobject? How can you say midiMess is an object and not track?
>
> track[m].midiMess.push({time:0,data0:0,data1:0,data2:0});
>
> function newTrack(m) {
> track[m] ={
> outport:[],
> portname : [],
> midichannel:[],
> program:[],
> midiMess:[{time:0,data0:0,data1:0,data2:0}]
> };
> return track;
> }
By the way they are both arrays "track,midiMess" and objects so it make them object arrays? But midiMess a subobject array to track?
[toc] | [prev] | [next] | [standalone]
| From | John G Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2018-01-22 10:47 +0000 |
| Message-ID | <86gb6ddabbi3aga2609e2need5absic73r@4ax.com> |
| In reply to | #34625 |
On Sun, 21 Jan 2018 20:03:50 -0800 (PST), Jonas Thörnvall
<jonas.thornvall@gmail.com> wrote:
>Den söndag 21 januari 2018 kl. 19:05:04 UTC+1 skrev John G Harris:
>> On Sun, 21 Jan 2018 04:10:05 -0800 (PST), Jonas Thörnvall
>> <jonas.thornvall@gmail.com> wrote:
>>
>> // Add another blank message to the track's midi messages
>> > track[m].midiMess.push({time:0,data0:0,data1:0,data2:0});
>>
>> I don't remember you saying you wanted to add another object to an
>> array. You just complained that you didn't know how to do it.
>>
>>
>> >Fuck you make me tired.
>>
>> Yes, that's the way to get help.
>>
>> John
>
>Well i showed you the structure didn't I?
Life's too short to remember everything you wrote.
>And i asked you howto create a midiMess didn't I?
>If you are a bit clueless of javascript syntax like me, then it ain't going to pop out of your brain by lookin at the structure, howto create a midiMess for that structure?
>
>And why you call track an array,
I didn't.
>isn't it an object?
Yes. An array is a special kind of object. It can be treated like
arrays in other programming languages.
But track[m] is an ordinary kind of object. The name "track" is
confusing; "tracks" would be more honest.
>If so what does that make midiMess a subobject?
midimess is a property of an *element* of the track array, not a
property of track.
>How can you say midiMess is an object and not track?
<snip>
I didn't. But midiMess is an array object, otherwise you wouldn't be
able to use a push method.
So what did you find difficult : accessing midiMess, or adding another
message to it ?
John
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-22 04:32 -0800 |
| Message-ID | <380d7510-683d-420c-9564-095c04ebcce5@googlegroups.com> |
| In reply to | #34628 |
Den måndag 22 januari 2018 kl. 11:47:17 UTC+1 skrev John G Harris:
> On Sun, 21 Jan 2018 20:03:50 -0800 (PST), Jonas Thörnvall
> <jonas.thornvall@gmail.com> wrote:
>
> >Den söndag 21 januari 2018 kl. 19:05:04 UTC+1 skrev John G Harris:
> >> On Sun, 21 Jan 2018 04:10:05 -0800 (PST), Jonas Thörnvall
> >> <jonas.thornvall@gmail.com> wrote:
> >>
> >> // Add another blank message to the track's midi messages
> >> > track[m].midiMess.push({time:0,data0:0,data1:0,data2:0});
> >>
> >> I don't remember you saying you wanted to add another object to an
> >> array. You just complained that you didn't know how to do it.
> >>
> >>
> >> >Fuck you make me tired.
> >>
> >> Yes, that's the way to get help.
> >>
> >> John
> >
> >Well i showed you the structure didn't I?
>
> Life's too short to remember everything you wrote.
>
> >And i asked you howto create a midiMess didn't I?
> >If you are a bit clueless of javascript syntax like me, then it ain't going to pop out of your brain by lookin at the structure, howto create a midiMess for that structure?
> >
> >And why you call track an array,
>
> I didn't.
>
> >isn't it an object?
>
> Yes. An array is a special kind of object. It can be treated like
> arrays in other programming languages.
>
> But track[m] is an ordinary kind of object. The name "track" is
> confusing; "tracks" would be more honest.
>
> >If so what does that make midiMess a subobject?
>
> midimess is a property of an *element* of the track array, not a
> property of track.
>
> >How can you say midiMess is an object and not track?
> <snip>
>
> I didn't. But midiMess is an array object, otherwise you wouldn't be
> able to use a push method.
>
> So what did you find difficult : accessing midiMess, or adding another
> message to it ?
>
> John
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.
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.
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.
[toc] | [prev] | [next] | [standalone]
| From | John G Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2018-01-22 16:32 +0000 |
| Message-ID | <kd4c6d5tpnnuotlbfei2ivckpo2v4oeio2@4ax.com> |
| In reply to | #34629 |
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.
>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
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-22 21:36 -0800 |
| Message-ID | <d37e2907-043f-4089-86e8-bf4e0e2c7338@googlegroups.com> |
| In reply to | #34632 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-23 01:22 -0800 |
| Message-ID | <89614a3e-67bf-4d8d-9d02-8f03687b8d79@googlegroups.com> |
| In reply to | #34635 |
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?
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-23 05:18 -0800 |
| Message-ID | <1da8c1a5-66df-4535-ad00-e1cff4279d6f@googlegroups.com> |
| In reply to | #34638 |
Den tisdag 23 januari 2018 kl. 10:22:22 UTC+1 skrev Jonas Thörnvall:
> 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?
How can i wait until the code that read midiports? "promise?" resolved, before init is called.
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess()
.then(success, failure);
}
function failure () {
console.error('No access to your midi devices.'+ + msg )
}
function success (midi) {
mid=midi;
inputs = midi.inputs.values();
// inputs outputs are Iterators
for (input = inputs.next(); input && !input.done; input = inputs.next()) {
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;
}
init(); //SHOULD WAIT TO THE MIDIPORTS FETCHED
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-23 05:38 -0800 |
| Message-ID | <0b750fc5-09d1-4f6c-9d1f-0ccb41e25d3d@googlegroups.com> |
| In reply to | #34643 |
Den tisdag 23 januari 2018 kl. 14:18:59 UTC+1 skrev Jonas Thörnvall:
> Den tisdag 23 januari 2018 kl. 10:22:22 UTC+1 skrev Jonas Thörnvall:
> > 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?
>
> How can i wait until the code that read midiports? "promise?" resolved, before init is called.
>
>
> if (navigator.requestMIDIAccess) {
> navigator.requestMIDIAccess()
> .then(success, failure);
> }
>
> function failure () {
> console.error('No access to your midi devices.'+ + msg )
> }
>
> function success (midi) {
> mid=midi;
> inputs = midi.inputs.values();
> // inputs outputs are Iterators
> for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> // each time there is a midi message call the onMIDIMessage function
> input.value.onmidimessage = onMIDIMessage;
> }
>
> init(); //SHOULD WAIT TO THE MIDIPORTS FETCHED
> }
Well i try to understand promises but i fail.
new Promise(function(success,failure) {
navigator.requestMIDIAccess();
}).then(function() {
init();
})
function failure () {
console.error('No access to your midi devices.'+ + msg )
}
function success (midi) {
mid=midi;
inputs = midi.inputs.values();
// inputs outputs are Iterators
for (input = inputs.next(); input && !input.done; input = inputs.next()) {
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;
}
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-23 05:44 -0800 |
| Message-ID | <6f298d28-5be7-42df-948d-e0733686a830@googlegroups.com> |
| In reply to | #34644 |
Den tisdag 23 januari 2018 kl. 14:38:22 UTC+1 skrev Jonas Thörnvall:
> Den tisdag 23 januari 2018 kl. 14:18:59 UTC+1 skrev Jonas Thörnvall:
> > Den tisdag 23 januari 2018 kl. 10:22:22 UTC+1 skrev Jonas Thörnvall:
> > > 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?
> >
> > How can i wait until the code that read midiports? "promise?" resolved, before init is called.
> >
> >
> > if (navigator.requestMIDIAccess) {
> > navigator.requestMIDIAccess()
> > .then(success, failure);
> > }
> >
> > function failure () {
> > console.error('No access to your midi devices.'+ + msg )
> > }
> >
> > function success (midi) {
> > mid=midi;
> > inputs = midi.inputs.values();
> > // inputs outputs are Iterators
> > for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> > // each time there is a midi message call the onMIDIMessage function
> > input.value.onmidimessage = onMIDIMessage;
> > }
> >
> > init(); //SHOULD WAIT TO THE MIDIPORTS FETCHED
> > }
>
> Well i try to understand promises but i fail.
>
> new Promise(function(success,failure) {
> navigator.requestMIDIAccess();
> }).then(function() {
> init();
> })
>
> function failure () {
> console.error('No access to your midi devices.'+ + msg )
> }
>
> function success (midi) {
> mid=midi;
> inputs = midi.inputs.values();
> // inputs outputs are Iterators
> for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> // each time there is a midi message call the onMIDIMessage function
> input.value.onmidimessage = onMIDIMessage;
> }
> }
Tried this one to
new Promise(function(success,failure) {
navigator.requestMIDIAccess();
}).then(function(init) {
})
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-23 06:07 -0800 |
| Message-ID | <dc241384-47df-469f-add9-b26cca3e15f2@googlegroups.com> |
| In reply to | #34645 |
Den tisdag 23 januari 2018 kl. 14:44:39 UTC+1 skrev Jonas Thörnvall:
> Den tisdag 23 januari 2018 kl. 14:38:22 UTC+1 skrev Jonas Thörnvall:
> > Den tisdag 23 januari 2018 kl. 14:18:59 UTC+1 skrev Jonas Thörnvall:
> > > Den tisdag 23 januari 2018 kl. 10:22:22 UTC+1 skrev Jonas Thörnvall:
> > > > 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?
> > >
> > > How can i wait until the code that read midiports? "promise?" resolved, before init is called.
> > >
> > >
> > > if (navigator.requestMIDIAccess) {
> > > navigator.requestMIDIAccess()
> > > .then(success, failure);
> > > }
> > >
> > > function failure () {
> > > console.error('No access to your midi devices.'+ + msg )
> > > }
> > >
> > > function success (midi) {
> > > mid=midi;
> > > inputs = midi.inputs.values();
> > > // inputs outputs are Iterators
> > > for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> > > // each time there is a midi message call the onMIDIMessage function
> > > input.value.onmidimessage = onMIDIMessage;
> > > }
> > >
> > > init(); //SHOULD WAIT TO THE MIDIPORTS FETCHED
> > > }
> >
> > Well i try to understand promises but i fail.
> >
> > new Promise(function(success,failure) {
> > navigator.requestMIDIAccess();
> > }).then(function() {
> > init();
> > })
> >
> > function failure () {
> > console.error('No access to your midi devices.'+ + msg )
> > }
> >
> > function success (midi) {
> > mid=midi;
> > inputs = midi.inputs.values();
> > // inputs outputs are Iterators
> > for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> > // each time there is a midi message call the onMIDIMessage function
> > input.value.onmidimessage = onMIDIMessage;
> > }
> > }
>
> Tried this one to
> new Promise(function(success,failure) {
> navigator.requestMIDIAccess();
> }).then(function(init) {
>
> })
Well i am lost i setInterval after success.
function success (midi) {
mid=midi;
inputs = midi.inputs.values();
// inputs outputs are Iterators
for (input = inputs.next(); input && !input.done; input = inputs.next()) {
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;
}
InitTime= setInterval(init,500);
}
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web