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!
Need help with syntax in script reference (probably simple)
-
- Posts: 69
- Joined: Fri Aug 05, 2005 4:10 pm
- Location: Orlando, Florida, USA
-
- Posts: 69
- Joined: Fri Aug 05, 2005 4:10 pm
- Location: Orlando, Florida, USA
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!
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!
-
- Posts: 69
- Joined: Fri Aug 05, 2005 4:10 pm
- Location: Orlando, Florida, USA
-
- Posts: 69
- Joined: Fri Aug 05, 2005 4:10 pm
- Location: Orlando, Florida, USA
I think I've figured out how to use SQL to get the entire Song Database:
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...
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
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...
-
- Posts: 69
- Joined: Fri Aug 05, 2005 4:10 pm
- Location: Orlando, Florida, USA
Woohoo! I think I got it (except backwards - but the concept is the same):
This would basically write out something like:
If anyone knows of a simpler way to do this, or better programmed, let me know!
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 " " & colSongs.StringByIndex(0) & "<br>"
colSongs.Next
Wend
QueryRes.Next
Wend
Code: Select all
John Doe
John Doe's Song #1
John Doe's Song #2
Jane Doeier
Jane Doeier's Song #1
-
- Posts: 2153
- Joined: Fri Jan 14, 2005 1:45 am
- Location: Germany
- Contact:
Here I ampsyxonova wrote:Looks like you will have to wait until Onkel_enno is onlile
@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
-
- Posts: 69
- Joined: Fri Aug 05, 2005 4:10 pm
- Location: Orlando, Florida, USA