/* 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