Guidance
指路人
g.yi.org
Software / Reginald / Examples / playmid.rex

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

  
/* An example of FUNCDEF'ing various Windows MCI high level
 * functions to play a MIDI file.
 */

OPTIONS "C_CALL LABELCHECK WINFUNC NOSOURCE"
LIBRARY rexxgui

DO
	/* Register the Windows OS function mciSendString() */
	FUNCDEF("mciSendString", "32u, str, void, 32u, void", "winmm")

	/* Register the Windows OS function mciGetErrorString(). We
	 * register it to return an error message with a maximum
	 * length of 260 characters.
	 */
	FUNCDEF("mciGetErrorString", "32u, 32u, str[260] stor, 32u", "winmm")

	CATCH FAILURE
		CONDITION("M")
		RETURN
END

/* ====================== Play a MIDI File ====================== */

/* Present REXX GUI's File dialog to pick out the file */

/* Store the filename in the variable FN. */
fn = ''

/* Present the dialog */
err = guifile('FN', 'EXISTING', 'Pick out a MIDI file', 'MIDI files (*.mid) | *.mid | All files (*.*) | *.*')
IF err = '' THEN DO

	/* Open a Sequencer device associated with that file and use the alias A_Song */
	err = mcisendstring('open "' || fn || '" type sequencer alias A_Song', 0, 0, 0)

	/* Check for an error */
	IF err \== 0 THEN DO

		mcigeterrorstring(err, buf, 260) 
		guisay(buf)

	END

	ELSE DO

		/* Play the midi (from beginning to end), and wait for this operation to complete */
		err = mcisendstring("play A_Song from 0 wait", 0, 0, 0)
		IF err \== 0 THEN DO
			mcigeterrorstring(err, buf, 260) 
			RXSAY(buf)
		END

		/* Close the sequencer device, and wait for this operation to complete */
		mcisendstring("close A_Song wait", 0, 0, 0)

	END

END

RETURN
掌柜推荐
 
 
¥420.00 ·
 
 
¥470.00 ·
 
 
¥890.00 ·
 
 
¥660.00 ·
 
 
¥748.00 ·
 
 
¥1,800.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-18 23:35:16