Need help with syntax in script reference (probably simple)

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

agapeincognito
Posts: 69
Joined: Fri Aug 05, 2005 4:10 pm
Location: Orlando, Florida, USA

Need help with syntax in script reference (probably simple)

Post by agapeincognito »

Please excuse the length of this, but if you take a moment to read it through, the answer is probably pretty simple for most of you...

I have been going through the sample scripts, posts here, and the Online Script Reference, but I'm having the hardest time figuring the following out! I do a lot of advanced J and VB scripting in almost every area EXCEPT database connectivity - my weakest area.

Basically, for initial learning for more advanced things to come, I just want to add a menu item in MM, which displays a simple dialog as follows:

- Header panel (with text)
- Web Control (with html - see below)
- Footer panel (with buttons)

I can do all of that - it is the Web Control contents I have a problem with. I want to write a line in the control for each song (track) entry in the database that includes the following:

Album - Artist - Track # - Track

I can't for the life of me figure out how to do it. Following the examples in other scripts, I think I know how to do it for Selected Tracks (i.e., selected in the main window), but I want to pull the entire DB list.

So, can someone provide me the syntax for this? I probably need to know both the connection syntax and the actual doc.write statement.

I think once I get this, the rest should be a lot easier to learn on my own...

Thanks!
agapeincognito
Posts: 69
Joined: Fri Aug 05, 2005 4:10 pm
Location: Orlando, Florida, USA

Post by agapeincognito »

Apparently I made this more complicated than it is because no one seems to know the answer! :)

Basically, I'm just looking for how to pull information from the ENTIRE database (of songs, for example) rather than just the selected tracks. For example, if I wanted to just simply print a list of all the songs in my database (just for learning - this obviously isn't the way to do this), how would I do it?

I just can't seem to figure out how to get to the right object (looking at the online object reference) without using the Selected Tracks and related items.

Thanks!
psyXonova
Posts: 785
Joined: Fri May 20, 2005 3:57 am
Location: Nicosia, Cyprus
Contact:

Post by psyXonova »

Looks like you will have to wait until Onkel_enno is onlile :lol: 8) :lol:
agapeincognito
Posts: 69
Joined: Fri Aug 05, 2005 4:10 pm
Location: Orlando, Florida, USA

Post by agapeincognito »

Waiting is what I do best! :)

Or is that worst? I guess I'll have to go ask my wife...
agapeincognito
Posts: 69
Joined: Fri Aug 05, 2005 4:10 pm
Location: Orlando, Florida, USA

Post by agapeincognito »

I think I've figured out how to use SQL to get the entire Song Database:

Code: Select all

Set QueryRes = SDB.Database.OpenSQL ("SELECT SongTitle FROM Songs")
     While Not QueryRes.EOF
     Doc.Write QueryRes.StringByIndex(0) & "<br>"
     QueryRes.Next
Wend
But using SQL confuses me even more. How would I take the result and then parse out all the information for each artist?

Let's say I look at the first song in the above query that is returned, and let's call it "My First Song". So the above would write out "My First Song" to the window, then advance to the next item in the query. Now, before advancing, let's say I wanted to write to a text file all the songs that are by the artist for My First Song...

Of course, I then advance to the next song in the query, "My Second Song", write the song title to the window, then want to write a text file for all the songs listed in my database for the artist of "My Second Song"...

so on, and so on...
agapeincognito
Posts: 69
Joined: Fri Aug 05, 2005 4:10 pm
Location: Orlando, Florida, USA

Post by agapeincognito »

Woohoo! I think I got it (except backwards - but the concept is the same):

Code: Select all

Set QueryRes = SDB.Database.OpenSQL ("SELECT ID, Artist FROM Artists")
While NOT QueryRes.EOF
     Doc.Write QueryRes.StringByIndex(1) & "<br>"
     Set colSongs = SDB.Database.OpenSQL ("SELECT SongTitle FROM Songs WHERE Songs.IDArtist = " & QueryRes.StringByIndex(0))
     While NOT colSongs.EOF
          Doc.Write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & colSongs.StringByIndex(0) & "<br>"
          colSongs.Next
     Wend
     QueryRes.Next
Wend
This would basically write out something like:

Code: Select all

John Doe
     John Doe's Song #1
     John Doe's Song #2
Jane Doeier
     Jane Doeier's Song #1
If anyone knows of a simpler way to do this, or better programmed, let me know!
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

psyxonova wrote:Looks like you will have to wait until Onkel_enno is onlile :lol: 8) :lol:
Image Here I am :lol:

@agapeincognito
You could use the QuerySongs-Listing - it will result the Songs-Objects but I think the way you did it is better, because so you have the ability to sort, ...

But it would look s.th. like that

Code: Select all

Dim RS
Set RS = SDB.Database.QuerySongs("AND Songs.IDArtist = 1920")

while not RS.EOF
	Doc.Write RS.Item.Title
	RS.Next
wend
Maybe you could use it anyhow.
agapeincognito
Posts: 69
Joined: Fri Aug 05, 2005 4:10 pm
Location: Orlando, Florida, USA

Post by agapeincognito »

Actually, I think that might solve a related issue! Thanks!
Post Reply