home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / CASEWORD.E < prev    next >
Text File  |  1992-08-26  |  3KB  |  57 lines

  1. ;I just wrote the following proc to rotate the  case of a word.  I find it
  2. ;handier to  use than  the default  C-F1 and  C-F2 keys.   I  have defined
  3. ;C-F10, but  any key will do.   I recommend  a Ctrl key since  the tabword
  4. ;functions are usually on Ctrl keys.
  5. ;
  6. ;Blair Thompson             Information Systems            IBM Canada Ltd.
  7.  
  8. /**********************************************************************/
  9. /* CASEWRD.E - Rotate Case of word pointed at by cursor between       */
  10. /*             UPPER, Mixed, and lower.                               */
  11. /*                                                                    */
  12. /* Words that are all uppercase  -> Cap1                              */
  13. /* Words that are all lowercase  -> Upper                             */
  14. /* Words that are all mixed case -> Lower                             */
  15. /*                                                                    */
  16. /* Thus, repeated invocations will give a rotation from               */
  17. /*   upper -> cap1 -> lower -> upper -> etc.                          */
  18. /*                                                                    */
  19. /* Note that only the first alphabetic string in the word is tested   */
  20. /* for case, although the case of the entire word is changed.         */
  21. /*                                                                    */
  22. /* Written by B. Thompson 6 Aug 1987                                  */
  23. /*                                                                    */
  24. /**********************************************************************/
  25.  
  26. def c_f10=
  27.   Call psave_mark(save_mark)
  28.   Call pmark_word()
  29.   getline line,.line                  /* Get word pointed to by cursor*/
  30.   getmark first_line,last_line,first_col,last_col
  31.   word_len = last_col - first_col + 1
  32.   wrd = Substr(line,first_col,word_len)
  33.   upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  34.   lower = 'abcdefghijklmnopqrstuvwxyz'
  35.   first = Verify(wrd,upper||lower,'M')/* First alphabetic            */
  36.   If first < 1 Then
  37.     first = 1
  38.   Endif
  39.   wrd = Substr(wrd,first)
  40.   last  = Verify(wrd,upper||lower) - 1/* Last alphabetic             */
  41.   If last < 1 Then
  42.     last = word_len - first + 1
  43.   Endif
  44.   wrd = Substr(wrd,1,last)             /* Alphabetic word             */
  45.   If Verify(wrd,upper) = 0 Then        /* All uppercase               */
  46.     Call plowercase()                  /* -> Capitalise               */
  47.     .cursorx = first_col + first - 1
  48.     mark_block
  49.     Call puppercase()
  50.   Elseif Verify(wrd,lower) = 0 Then    /* All lowercase               */
  51.     Call puppercase()                  /* -> uppercase                */
  52.   Else                                 /* Mixed case                  */
  53.     Call plowercase()                  /* -> lowercase                */
  54.   Endif
  55.   Call prestore_mark(save_mark)
  56.  
  57.