'Expected input format: 'artist|title|songtype|duration in milliseconds^ 'Examples: 'Metallica|Until it sleeps|S|340000^ 'Advertisement|Dial Direct Insurance|A|60000^ '####################################################################################### '## Custom Param Processing '####################################################################################### Function ProcessParams(Params, ParamCount) If ParamCount <> 4 Then Log("ParamCount expected to be 4, but " & ParamCount & " params returned. Aborting.") Exit Function End If SongInfo.Value("artist") = Params(0) SongInfo.Value("title") = Params(1) SongInfo.Value("songtype") = Params(2) SongInfo.Value("duration") = Int(Params(3)) SongInfo.DoSongChange 'Triggers the metadata update in SAM Cast End Function '####################################################################################### '## ALL of the functions below were taken from the vb.library.txt code snipped file '## This file contains all the code snippets you need for most metadata handling. '####################################################################################### 'Data events are separated via a known separator character 'In this case the character is ^ 'NOTE: We also strip out any potential CR and LF characters, just in case (\n\r) 'This handler could handle data in this form: 'Metallica|Until it sleeps|S|340000^Advertisement|Dial Direct Insurance|A|60000^ Function HandleLine(sLine) const RecordEnd = "^" Dim P Dim Data Dim Params(20) Dim ParamCount Log("Line-in: " & sLine) sLine = TrimLineFeed(sLine) 'Remove NewLine and LineFeed special characters if they exist P = InStr(sLine,RecordEnd ) While (P > 0) Data = Mid(sLine,1,P-1) sLine = Mid(sLine,P+1,Len(sLine)) ExtractParams Data, Params, ParamCount ProcessParams Params, ParamCount P = InStr(sLine, RecordEnd) Wend 'If any portion of the line is left over 'return it so we can append more data to it HandleLine = sLine If sLine <> "" Then Log("Line-out: " & sLine) End If End Function 'Split line into Params using a known "splitter" character that seperates the data ' Usage: ' Dim Params(20) ' Dim ParamCount ' ExtractParams sLine, Params, ParamCount ' NOTE: sLine above is for example "artist|title|S|03:35" Function ExtractParams(sLine, ByRef Params, ByRef ParamCount) const FieldSplitter = "|" Dim P Dim Data ParamCount = 0 P = InStr(sLine,FieldSplitter) While (P > 0) Data = Trim(Mid(sLine,1,P-1)) sLine = Mid(sLine,P+1,Len(sLine)) AddParam Data, Params, ParamCount P = InStr(sLine, FieldSplitter) Wend If sLine <> "" Then AddParam sLine, Params, ParamCount End If End Function 'Remove the EOL and LF characters from a string 'Usage: cleanLine = TrimLineFeed(sourceLine) Function TrimLineFeed(sLine) sLine = Replace(sLine,Chr(13),"") sLine = Replace(sLine,Chr(10),"") TrimLineFeed = sLine End Function 'Add a new parameter value and increase the counter 'NOTE: White space is removed from Data Function AddParam(Data, ByRef Params, ByRef ParamCount) Data = Trim(Data) SongInfo.Log("Param" & ParamCount & ": " & Data) Params(ParamCount) = Data ParamCount = ParamCount + 1 End Function 'Simple function that wraps the logging method so you have to do less typing Function Log(Msg) SongInfo.Log(Msg) End Function