Scripts in 4.0.3

Post a reply

Visual Confirmation

To prevent automated access and spam, you are required to confirm that you are human. Please place a check mark next to all images of monkeys or apes. If you cannot see any images, please contact the Board Administrator.

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: Scripts in 4.0.3

Re: Scripts in 4.0.3

Post by Thanasis » Sat Mar 31, 2012 10:22 pm

Why don't you try your code by deducting some code at a time so you see where is the problem ?????

I see you are writing to a log file. Try without it and see what happens.

If you find the section which causes you problems, post back.....

Take Care
Athas

Scripts in 4.0.3

Post by jon_beeker » Sat Mar 24, 2012 1:38 pm

Hello All,
I just updated from 3.? to 4.0.3 and now most of my scripts don't work. Here is something really simple that would delete all ratings from 20K songs in minutes. Now it starts and takes hours if it doesn't hang after a while (message box appears saying program has become non-responsive). Any thought?

Code: Select all

Option Explicit

Public LogDebug
LogDebug = True


Sub test
logme "test"

Dim Line
Set Line = SDB.Progress
Dim plSongs
Dim Iter

Dim count
count = 0

'-------------------------------clears old ratings-------------------------------

Set plSongs = SDB.Database.OpenSQL("SELECT ID FROM Songs WHERE ID>0 AND RATING <>-1")

While Not plSongs.EOF
count = count +1
Set Iter = SDB.Database.QuerySongs( "ID=" & plSongs.ValueByIndex(0))
Line.Text = "Deleting old ratings...."

Iter.item.rating = -1
Line.Text = "Deleting old ratings...."&count
logme count &"-"& Iter.item.Title
SDB.Database.Commit
SDB.Database.BeginTransaction
Iter.Item.UpdateDB
SDB.Database.Commit       


plSongs.Next
Wend



'-------------------------------end clears old ratings-------------------------------

End Sub



'---------------------------
'this is just the log script
'---------------------------

Sub logme(msg)
if LogDebug then
    Dim fso, logf
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set logf = fso.OpenTextFile("C:\Program Files\MediaMonkey\Scripts\debug.log",8,True,-1)
    logf.WriteLine Now() & ": " & msg
    Set fso = Nothing
    Set logf = Nothing
End If

End Sub   



Top