home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Sound / Misc / MUSICX21.DMS / in.adf / rexx / TrimEnd.mxe < prev    next >
Encoding:
Text File  |  1993-10-13  |  1.2 KB  |  44 lines

  1. /*  TrimEnd.mxe
  2.  
  3.     RexxEdit example ARexx macro program
  4.  
  5.     Removes all events after the END event.
  6.  
  7.     (If there are multiple END markers in the sequence, it removes all
  8.     events after first one, including the other end events.)
  9. */
  10.  
  11.  
  12. options results                            /* always include this command    */
  13.  
  14. MXPOINTER "sleepy"                        /* show user we're working        */
  15.  
  16. WeFoundTheEnd = 'false'                    /* initialize some variables    */
  17. EventsRemoved = 0
  18.  
  19. BEGINSCAN 'all'                            /* begin scan of all events        */
  20. if result ~= 0 then do forever            /* 0 if error                    */
  21.  
  22.   NEXTEVENT                                /* get next event in sequence    */
  23.   if result == 0 then break    /* 0 if no more events, break do forever    */
  24.  
  25.   if WeFoundTheEnd == 'false' then do    /* if still looking for END     */
  26.     if EVENT.TYPE == 'END' then WeFoundTheEnd = 'true'    /* ah! found it    */
  27.     end
  28.   else do
  29.     REMEVENT                            /* if after END, remove it        */
  30.     EventsRemoved = EventsRemoved + 1    /* add one to removal count        */
  31.     end
  32.  
  33. end                                        /* end of do forever, do again    */
  34. ENDSCAN                                    /* end scan                        */
  35.  
  36. MXPOINTER "normal"                        /* we're done                    */
  37.  
  38.     /* report results...    */
  39.  
  40. if EventsRemoved ~= 1 then MXREPORT "Removed" EventsRemoved "events."
  41. else MXREPORT "Removed 1 event."        /* for good English                */
  42.  
  43. exit
  44.