Guidance
指路人
g.yi.org
Software / Reginald / Examples / rxmidi examples / setname.rex

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/* Sets all track name events to "Track XX" where XX is the track number.
 */

OPTIONS "C_CALL LABELCHECK NOSOURCE"

/* Add the REXX GUI and RxMidi functions. */
LIBRARY rexxgui, rxmidi

/* Trap errors in RxMidi functions. So, we don't have to check the return values
 * from MIDI REXX functions that set the ERROR condition, such as MIDISetEvent().
 */
midierr = "ERROR"
midiheading = 1

/* Print an introduction */
IF guisay('This script sets all track name events to "Track XX" where XX is the track number. Proceed?', 'YES|INFO') \= 'YES' THEN SIGNAL out

/* Check if we have a MIDI file name. We get the filename from
 * the command line (ie, the user typed it after disasm.rex), or
 * if not supplied, we bring up the file dialog.
 */
IF ARG() < 1 THEN DO
	ERROR = guifile('FromFilename', 'EXISTING', 'Enter a name for the new MIDI file', 'MIDI files (*.mid, *.rmi) | *.mid;*.rmi | All files (*.*) | *.*')
	IF ERROR \= "" THEN SIGNAL out
END
ELSE fromfilename = ARG(1)

/* Check if we have a MIDI file name. We get the filename from
 * the command line (ie, the user typed it after disasm.rex), or
 * if not supplied, we bring up the file dialog.
 */
IF ARG() < 1 THEN DO
	ERROR = guifile('FromFilename', 'EXISTING', 'Enter a name for the new MIDI file', 'MIDI files (*.mid, *.rmi) | *.mid;*.rmi | All files (*.*) | *.*')
	IF ERROR \== "" THEN RETURN
END
ELSE fromfilename = ARG(1)

DO
	/* Open a MIDI file */
	MIDIOpenFile(fromfilename)

	/* Move to the start of the next track */
	DO WHILE MIDITrack("") \= 0

		/* For each Track Name event in this track... */
		DO WHILE MIDIGetEvent('Trac') = ""

			midievent.!data1 = "Track" MIDITrack()
			MIDISetEvent('DATA')

		END /* DO WHILE MIDIGetEvent */

	END /* DO WHILE MIDITrack */

	/* Save to a MIDI file with an underscore prepended to the name */
	/*
	name = FILESPEC('N', FromFilename)
	path = LEFT(FromFilename, LENGTH(FromFilename) - LENGTH(name))
	MIDISaveFile(path || '_' || name)
*/

	CATCH ERROR
		CONDITION('M')
END

RETURN
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Tue 2024-4-23  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:49:22