How to Get Trimmed MIDI file Name

Hi,

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:

Snag_1af1de7

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.)

CopySubstring

(See the documentation of all script functions. It is in the help menu)

And here:

https://gigperformer.com/docs_5_0/SystemFunctionList.html

2 Likes

Try this…

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).

2 Likes

Where exactly did you look? The string functions are clearly listed in the system function list (which can be reached from our support page)

Places other than here, unfortunately:

Snag_225e521

Mea culpa.