VBScript Scripting object question

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

ianbradbury67

VBScript Scripting object question

Post by ianbradbury67 »

All,
hoping this is a simple question - my coding is a bit rusty!
I've written a script to trim redundant characters from the end of (for example) the album name. I want to make it generic so I can pass in the field I want to trim.
So far I've got:

Code: Select all

' Get list of selected tracks from MediaMonkey
	Set list = SDB.SelectedSongList 
	If list.count=0 Then 
		Set list = SDB.AllVisibleSongList 
	End If  

	If pField = "Title" Then
		tmp = list.item(0).Title
	Else
		If pField = "Album" Then
			tmp = list.item(0).AlbumName
		Else
			If pField = "Artist" Then
				tmp = list.item(0).ArtistName
			Else
				MsgBox "Invalid field name: " & pField, vbOKOnly + vbExclamation
				Exit Sub
			End If
		End If
	End If
But rather than the convoluted nested if statement (or a replacement case statement) I'd like to pick the field dynamically. Something like:
tmp = list.item(0).field(pField)

So I can use pField to pick the relevant field to edit?
Peke
Posts: 17446
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: VBScript Scripting object question

Post by Peke »

Why don't you use Simple Dropdown selection of desired field or even table/group selection of fields to trim?

It would be easier to maintain and debug.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
Post Reply