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


Groups > comp.lang.javascript > #38114 > unrolled thread

Approach to find out parsed values that goes wrong?

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2020-01-22 21:25 -0800
Last post2020-01-24 21:32 -0800
Articles 7 on this page of 27 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 21:25 -0800
    Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 22:05 -0800
      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 22:10 -0800
        Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 22:41 -0800
          Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 23:12 -0800
      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 22:27 -0800
    Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-23 04:50 -0800
      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 06:12 -0800
      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 06:33 -0800
      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 06:55 -0800
        Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-23 11:48 -0800
          Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 14:54 -0800
            Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 14:58 -0800
              Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 15:00 -0800
                Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 15:20 -0800
            Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-23 17:59 -0800
              Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-24 01:03 -0800
                Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-24 05:38 -0800
                  Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-24 11:23 -0800
                    Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-24 17:12 -0800
                      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-25 06:48 -0800
                      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-26 11:22 -0800
                        Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-26 14:17 -0800
                          Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-26 22:38 -0800
                            Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-28 05:13 -0800
                              Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-28 17:35 -0800
                    Re: Approach to find out parsed values that goes wrong? luserdroog <luser.droog@gmail.com> - 2020-01-24 21:32 -0800

Page 2 of 2 — ← Prev page 1 [2]


#38140

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-25 06:48 -0800
Message-ID<1b0baa82-195b-4e14-846f-b28ec4de1483@googlegroups.com>
In reply to#38138
Den lördag 25 januari 2020 kl. 02:12:35 UTC+1 skrev Michael Haufe (TNO):
> On Friday, January 24, 2020 at 1:23:17 PM UTC-6, Jonas Thörnvall wrote:
> 
> > Yeah that require the importedMidi to be a JSON object i guess, but what is actually parsedMidi???
> 
> 
> The bigger question is where did you use my JSON.parse() suggestion?

Why would i use it if i do not know what it puts out?

[toc] | [prev] | [next] | [standalone]


#38141

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-26 11:22 -0800
Message-ID<ee1dcdac-dd4d-4c3d-aeda-48890bd759f9@googlegroups.com>
In reply to#38138
Den lördag 25 januari 2020 kl. 02:12:35 UTC+1 skrev Michael Haufe (TNO):
> On Friday, January 24, 2020 at 1:23:17 PM UTC-6, Jonas Thörnvall wrote:
> 
> > Yeah that require the importedMidi to be a JSON object i guess, but what is actually parsedMidi???
> 
> 
> The bigger question is where did you use my JSON.parse() suggestion?

I hope you see that my problem is to get whatever the JSON puts out into my array object format, track[x].message[y].time and so on.

To do that i disassembled the string into pieces. You say i should however go directly from the JSON source events and somehow fit them into my array objects, how do you even start such endeavour. Are the JSON thingies in an array? How do i map them one to one with my array objects? "time, note etc etc"

If you show me howto just parse the time object/attribute i may get a hang of it.

[toc] | [prev] | [next] | [standalone]


#38142

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2020-01-26 14:17 -0800
Message-ID<25223969-727f-48b9-8c9b-6a5e0448024d@googlegroups.com>
In reply to#38141
On Sunday, January 26, 2020 at 1:22:50 PM UTC-6, Jonas Thörnvall wrote:
> Den lördag 25 januari 2020 kl. 02:12:35 UTC+1 skrev Michael Haufe (TNO):
> > On Friday, January 24, 2020 at 1:23:17 PM UTC-6, Jonas Thörnvall wrote:
> > 
> > > Yeah that require the importedMidi to be a JSON object i guess, but what is actually parsedMidi???
> > 
> > 
> > The bigger question is where did you use my JSON.parse() suggestion?
> 
> I hope you see that my problem is to get whatever the JSON puts out into my array object format, track[x].message[y].time and so on.
> 
> To do that i disassembled the string into pieces. You say i should however go directly from the JSON source events and somehow fit them into my array objects, how do you even start such endeavour. Are the JSON thingies in an array? How do i map them one to one with my array objects? "time, note etc etc"
> 
> If you show me howto just parse the time object/attribute i may get a hang of it.


You're using @tonejs/midi.

You've supplied the following midi file:
<http://www.piano-midi.de/midis/chopin/chpn_op66.mid>

Using the midi you supplied earlier on the demo site yields the format the library provides you <https://tonejs.github.io/Midi/>


Looking at the source code on the page shows how this is performed:

```javascript
let currentMidi = null

function parseFile(file){
    //read the file
    const reader = new FileReader()
    reader.onload = function(e){
        const midi = new Midi(e.target.result)
        document.querySelector("#ResultsText").value = JSON.stringify(midi, undefined, 2)
        document.querySelector('tone-play-toggle').removeAttribute('disabled')
        currentMidi = midi
    }
    reader.readAsArrayBuffer(file)
}
```

Seems straightforward enough to me.

[toc] | [prev] | [next] | [standalone]


#38143

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-26 22:38 -0800
Message-ID<d160a8e4-d884-4902-8a5e-4258449977f7@googlegroups.com>
In reply to#38142
Den söndag 26 januari 2020 kl. 23:17:12 UTC+1 skrev Michael Haufe (TNO):
> On Sunday, January 26, 2020 at 1:22:50 PM UTC-6, Jonas Thörnvall wrote:
> > Den lördag 25 januari 2020 kl. 02:12:35 UTC+1 skrev Michael Haufe (TNO):
> > > On Friday, January 24, 2020 at 1:23:17 PM UTC-6, Jonas Thörnvall wrote:
> > > 
> > > > Yeah that require the importedMidi to be a JSON object i guess, but what is actually parsedMidi???
> > > 
> > > 
> > > The bigger question is where did you use my JSON.parse() suggestion?
> > 
> > I hope you see that my problem is to get whatever the JSON puts out into my array object format, track[x].message[y].time and so on.
> > 
> > To do that i disassembled the string into pieces. You say i should however go directly from the JSON source events and somehow fit them into my array objects, how do you even start such endeavour. Are the JSON thingies in an array? How do i map them one to one with my array objects? "time, note etc etc"
> > 
> > If you show me howto just parse the time object/attribute i may get a hang of it.
> 
> 
> You're using @tonejs/midi.
> 
> You've supplied the following midi file:
> <http://www.piano-midi.de/midis/chopin/chpn_op66.mid>
> 
> Using the midi you supplied earlier on the demo site yields the format the library provides you <https://tonejs.github.io/Midi/>
> 
> 
> Looking at the source code on the page shows how this is performed:
> 
> ```javascript
> let currentMidi = null
> 
> function parseFile(file){
>     //read the file
>     const reader = new FileReader()
>     reader.onload = function(e){
>         const midi = new Midi(e.target.result)
>         document.querySelector("#ResultsText").value = JSON.stringify(midi, undefined, 2)
>         document.querySelector('tone-play-toggle').removeAttribute('disabled')
>         currentMidi = midi
>     }
>     reader.readAsArrayBuffer(file)
> }
> ```
> 
> Seems straightforward enough to me.

I am so unused when it comes to read others code and interpretate it.

But i think i already to what you suggest it is that string i reparse, here is my code that i use to get the textstring, to main object?

Although is did cross out querySelector and replaced it, so what does querySelector do and hold?

Instead i just store the string in a variable "parsedMidi" that is sent to the parent document.

I think i ask what do i gain using querySelection and where does the "text?" go?
Mine "textstring" go to the variable parsedMidi.

Exactly what is #ResultsText? an inputfield? or what?
I think much of the new syntac is very sloppy, you can read the code without understand what it do acheive?

I mean document.querySelector, what the fuck is that supposed to mean?
If this is some weird  DB select format, anyway i think the syntax terrible.
Why not use. stringofmuppets=document.select.from."that".where(A==10,B==7,C=="monkeysyntax")

I mean WTF does this mean, who comes up with this elaborate shit syntax?
document.querySelector("#ResultsText").value = JSON.stringify(midi, undefined, 2)

function parseFile(file){
	//read the file
	const reader = new FileReader()
	reader.onload = function(e){
	const midi = new Midi(e.target.result)
	//document.querySelector("#ResultsText").value = JSON.stringify(midi, undefined, 2)
	parsedMidi=JSON.stringify(midi, undefined, 2)
	}
	reader.readAsArrayBuffer(file)
}
		

function sendParent(){
	parent.importedMidi = parsedMidi;
	parent.reparseMidi();
}

[toc] | [prev] | [next] | [standalone]


#38167

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2020-01-28 05:13 -0800
Message-ID<5b00c809-1694-49df-8df7-123347d5b934@googlegroups.com>
In reply to#38143
On Monday, January 27, 2020 at 12:38:12 AM UTC-6, Jonas Thörnvall wrote:
> Although is did cross out querySelector and replaced it, so what does querySelector do and hold?

As the name suggests, it queries the document with a CSS Selector:

<https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector>


> Exactly what is #ResultsText? an inputfield? or what?

References in the document irrelevant to the task as your page is different.

> I think much of the new syntac is very sloppy, you can read the code without understand what it do acheive?

You're not in a position to judge when you don't understand.

> I mean document.querySelector, what the fuck is that supposed to mean?
> If this is some weird  DB select format, anyway i think the syntax terrible.
> Why not use. stringofmuppets=document.select.from."that".where(A==10,B==7,C=="monkeysyntax")

#1 That wouldn't do what you think it would due to eager evaluation.
#2 using querySelector and querySelectorAll with array methods is more general 

> I mean WTF does this mean, who comes up with this elaborate shit syntax?
> document.querySelector("#ResultsText").value = JSON.stringify(midi, undefined, 2)

The html input element with the id "ResultsText" has its value set to the JSON string created from the midi variable

[toc] | [prev] | [next] | [standalone]


#38176

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-28 17:35 -0800
Message-ID<ecbef7f4-bf44-4c86-a0c5-35c12ea622a1@googlegroups.com>
In reply to#38167
Den tisdag 28 januari 2020 kl. 14:13:28 UTC+1 skrev Michael Haufe (TNO):
> On Monday, January 27, 2020 at 12:38:12 AM UTC-6, Jonas Thörnvall wrote:
> > Although is did cross out querySelector and replaced it, so what does querySelector do and hold?
> 
> As the name suggests, it queries the document with a CSS Selector:
> 
> <https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector>
> 
> 
> > Exactly what is #ResultsText? an inputfield? or what?
> 
> References in the document irrelevant to the task as your page is different.
> 
> > I think much of the new syntac is very sloppy, you can read the code without understand what it do acheive?
> 
> You're not in a position to judge when you don't understand.
> 
> > I mean document.querySelector, what the fuck is that supposed to mean?
> > If this is some weird  DB select format, anyway i think the syntax terrible.
> > Why not use. stringofmuppets=document.select.from."that".where(A==10,B==7,C=="monkeysyntax")
> 
> #1 That wouldn't do what you think it would due to eager evaluation.
> #2 using querySelector and querySelectorAll with array methods is more general 
> 
> > I mean WTF does this mean, who comes up with this elaborate shit syntax?
> > document.querySelector("#ResultsText").value = JSON.stringify(midi, undefined, 2)
> 
> The html input element with the id "ResultsText" has its value set to the JSON string created from the midi variable

Well i do not mind you use tags for selection they are attribute to the query and the string you look for. But i mind the monkeysyntax its unbearable drivel. A five year old could come up with something more concise and telling.

It is basicly like someone just thrown word together but do not understand the connection to the underlying action and query?

It is a query that acts on HTML tags and the content of tags. Using some defined attributes to do a select. Shold not that somehow be possilbe to interpretate from the string the monkey threw together?

[toc] | [prev] | [next] | [standalone]


#38139

Fromluserdroog <luser.droog@gmail.com>
Date2020-01-24 21:32 -0800
Message-ID<157583e5-cf44-49d8-9025-3170f1f23a96@googlegroups.com>
In reply to#38137
On Friday, January 24, 2020 at 1:23:17 PM UTC-6, Jonas Thörnvall wrote:
> Den fredag 24 januari 2020 kl. 14:39:01 UTC+1 skrev Michael Haufe (TNO):
> > On Friday, January 24, 2020 at 3:03:52 AM UTC-6, Jonas Thörnvall wrote:
> > > Den fredag 24 januari 2020 kl. 02:59:32 UTC+1 skrev Michael Haufe (TNO):
> > > > [...]
> > > > 
> > > > Why not just do:
> > > > 
> > > > ```
> > > > var parsedMidi = JSON.parse(importedMidi)
> > > > ```
> > > 
> > > And exactly what would that achieve?
> > 
> > If `importedMidi` is the string representing what you showed us in your second post then it would achieve a complete parse and you can throw away the rest of your code as redundant.
> > 
> > You shouldn't have to do any parsing at all yourself.
> 
> Yeah that require the importedMidi to be a JSON object i guess, but what is actually parsedMidi???

It would be a regular JavaScript object. The Midi parsing library
should document the internal structure of the object.

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.javascript


csiph-web