backward.fnc 1.3 KB

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