VBScript Scripting object question

Post a reply

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: VBScript Scripting object question

Re: VBScript Scripting object question

by Peke » Sun Jun 07, 2020 7:40 pm

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.

VBScript Scripting object question

by ianbradbury67 » Fri Jun 05, 2020 10:03 am

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?

Top