Indeed, "front-door" *is* the way to go.
(other reasons already explained in my previous post)
This will work:
- Code: Select all
Dim MySongIter, MySong, strWhere
strWhere = "AND Songs.ID=" & LastSongsID
Set MySongIter = SDB.Database.QuerySongs(strWhere)
If Not MySongIter.EOF Then
Set MySong = MySongIter.Item
MySong.Rating = 50
I forgot that the QuerySongs function returns a SDBSongIterator object, not a SDBSongData object.
To get the SDBSongData object from the iterator, you have to use .Item
So "songdata = songiterator.Item"
(it's all in the scripting reference, if you were wondering how I knew that)
What the code does:
-Declaring the variables (using Dim)
-Using QuerySongs, getting the SDBSongIterator object, filled with all SDBSongData objects that suit the strWhere condition(s).
-Check if there is an entry in the iterator (in this case, check if there really was a song with ID = LastSongsID) so there will never be an error if you supply a wrong LastSongsID.
-Get the current (first and only) SDBSongData object from the iterator (using .Item), and call it MySong.
-Change the rating for the song's object.
-Let MM update the database (and internal data and GUI and file tags).
(make sure you understand every line of code you write)
BTW: Pablo hasn't been seen here for months, so probably he won't respond to your message anymore. (It's him that wrote the MagicNodes script, now becoming out-of-date).