Can anyone show me how to get the trimmed MIDI file name in a GP script?
What I mean is, just the name of the actual MIDI file, without " N - " in front of it.
Using Param 0 of the MFP returns a string with all that extra info prepended, like so:
However, I would like to write my script to take conditional action which depends on the actual MIDI file name, but without reference to where it lives in the MFP list.
Hence, I want to trim that leading info (correctly, regardless of index number).
(P.S. I looked for a list of string functions in the docs and could not find one.)
var
MidiPlayer : PluginBlock
separatorString : string = " - "
function GetTrimmedName (sourceString: string) returns String
result = StringAfterFirstOccurrence(sourceString, separatorString, false, true)
End
// Called automatically after script is loaded
Initialization
OpenLogWindow()
Print (GetTrimmedName(GetParameterText(MidiPlayer, 0)))
End
I put the string function in a separate user function because i thought that it might make multiple use a bit easier (shorter syntax). You can of course use the actual GP-script function directly, if you prefer.
Since the Midi player always separates the song number from the song title with a " - " this will also be the separator for the string function, which will return all the rest of the source string after the separator string has been found (like its name already says).