Need help with syntax in script reference (probably simple)

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Need help with syntax in script reference (probably simple)

Postby agapeincognito » Fri Aug 12, 2005 2:27 pm

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

Postby agapeincognito » Wed Aug 31, 2005 9:11 am

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!
agapeincognito
 
Posts: 69
Joined: Fri Aug 05, 2005 4:10 pm
Location: Orlando, Florida, USA

Postby psyXonova » Wed Aug 31, 2005 9:29 am

Looks like you will have to wait until Onkel_enno is onlile :lol: 8) :lol:
psyXonova
 
Posts: 785
Joined: Fri May 20, 2005 3:57 am
Location: Nicosia, Cyprus

Postby agapeincognito » Wed Aug 31, 2005 10:12 am

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

Postby agapeincognito » Wed Aug 31, 2005 3:54 pm

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

Postby agapeincognito » Wed Aug 31, 2005 4:21 pm

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!
agapeincognito
 
Posts: 69
Joined: Fri Aug 05, 2005 4:10 pm
Location: Orlando, Florida, USA

Postby onkel_enno » Thu Sep 01, 2005 12:37 am

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.
SansaMonkey - for SanDisk Sansa and Rockbox Users

Please no PMs for Questions which should be asked in the Forum. Thx
onkel_enno
 
Posts: 2145
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany

Postby agapeincognito » Thu Sep 01, 2005 8:23 am

Actually, I think that might solve a related issue! Thanks!
agapeincognito
 
Posts: 69
Joined: Fri Aug 05, 2005 4:10 pm
Location: Orlando, Florida, USA


Return to Need Help with Addons?

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 14 guests