Page 1 of 1

Custom field update script

Posted: Mon Jan 23, 2006 7:13 am
by Paven
Hello o hej
I have problem with assigning a value to my custom string.
basicly i got custom 3 as "Main Artist" i MM and would like i script that updates god "Album artist" or god "artist" on demand.
i sorting i use this field to sort artists to gether like John Lennon would have the beatles as Main artist.

thsi script supose to take album artist information or if not present artist information and stor it as "Main Artist" but i get an "Object Requierd" erro at line 15 colum 4

anyon with morexperiance that would help?

Code: Select all

'[CreateMainArtistName]
'FileName=CreateMainArtistName.vbs
'ProcName=CreateMainArtistName
'Order=1
'DisplayName=Create Main Artist
'Description=Copy AlbumArtistName or ArtistName to Main Artist
'Language=VBScript
'ScriptType=0

Sub CreateMainArtistName
  Dim list, itm, i
  Set list = SDB.CurrentSongList
  For i=0 To list.count-1
    Set itm = list.Item(i)
    If itm.Custom3 Is "" Then
      If itm.AlbumArtistName is "" Then
        itm.Custom3 = itm.ArtistName
      else
        itm.Custom3 = itm.AlbumArtistName
    end if
  end if
  Next
  list.UpdateAll
End Sub
ps i wish for an grouping function for artists in the futere.. making this scipt obsolete :)

Posted: Mon Jan 23, 2006 7:17 am
by trixmoto
Is compares objects, you want to be comparing strings. Try this:

Code: Select all

'[CreateMainArtistName]
'FileName=CreateMainArtistName.vbs
'ProcName=CreateMainArtistName
'Order=1
'DisplayName=Create Main Artist
'Description=Copy AlbumArtistName or ArtistName to Main Artist
'Language=VBScript
'ScriptType=0

Sub CreateMainArtistName
  Dim list, itm, i
  Set list = SDB.CurrentSongList
  For i=0 To list.count-1
    Set itm = list.Item(i)
    If itm.Custom3 = "" Then
      If itm.AlbumArtistName = "" Then
        itm.Custom3 = itm.ArtistName
      else
        itm.Custom3 = itm.AlbumArtistName
    end if
  end if
  Next
  list.UpdateAll
End Sub

Posted: Mon Jan 23, 2006 9:03 am
by Paven
Thanx it works now.
i am new to this language so i axpect everything to be more complex :)

Posted: Mon Jan 23, 2006 10:50 am
by trixmoto
Yeah, almost everyday I use Uniface, VBScript and Delphi - I tend to get lots of compilation errors because I'm mixing my syntaxes! :)

Re: Custom field update script

Posted: Wed Feb 03, 2021 2:14 am
by JohnnyTaylor
Hi, pavan, I want to say thank you for asking for the code, actually, I was also searching for the same. I am also new to this language and using this in a jumble solver code that is required for word games.