home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / os2tk21j / rexx / samples / callrexx / backward.fn_ / backward.fnc
Encoding:
Text File  |  1993-03-12  |  1.3 KB  |  20 lines

  1. /*********************************************************************/
  2.  
  3. /* BACKWARD.FNC - Reverse the words in a string                      */
  4.  
  5. /*                                                                   */
  6.  
  7. /* This program is called by CALLREXX.EXE.                           */
  8.  
  9. /*                                                                   */
  10.  
  11. /* Input:  A string of words                                         */
  12.  
  13. /*                                                                   */
  14.  
  15. /* Output: A string containing the same words but in opposite order  */
  16.  
  17. /*                                                                   */
  18.  
  19. /*********************************************************************/
  20.  
  21. Parse Arg Data                         /* get argument string        */
  22.  
  23. OutString = ''                         /* initialize output to empty */
  24.  
  25. Count = Words(Data)                    /* find number of words       */
  26.  
  27. Do i = Count To 1 By -1                /* for each word in string    */
  28.  
  29.    OutString = OutString Word(Data,i)  /*   add word to output string*/
  30.  
  31.    End /* end do */
  32.  
  33. Return Strip(OutString)                /* return reversed string,    */
  34.  
  35.                                        /* removing any blanks on the */
  36.  
  37.                                        /* front or back.             */
  38.  
  39.