home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
wps
/
editor
/
epmtools
/
epmsmp
/
caseword.e
< prev
next >
Wrap
Text File
|
1992-08-26
|
3KB
|
57 lines
;I just wrote the following proc to rotate the case of a word. I find it
;handier to use than the default C-F1 and C-F2 keys. I have defined
;C-F10, but any key will do. I recommend a Ctrl key since the tabword
;functions are usually on Ctrl keys.
;
;Blair Thompson Information Systems IBM Canada Ltd.
/**********************************************************************/
/* CASEWRD.E - Rotate Case of word pointed at by cursor between */
/* UPPER, Mixed, and lower. */
/* */
/* Words that are all uppercase -> Cap1 */
/* Words that are all lowercase -> Upper */
/* Words that are all mixed case -> Lower */
/* */
/* Thus, repeated invocations will give a rotation from */
/* upper -> cap1 -> lower -> upper -> etc. */
/* */
/* Note that only the first alphabetic string in the word is tested */
/* for case, although the case of the entire word is changed. */
/* */
/* Written by B. Thompson 6 Aug 1987 */
/* */
/**********************************************************************/
def c_f10=
Call psave_mark(save_mark)
Call pmark_word()
getline line,.line /* Get word pointed to by cursor*/
getmark first_line,last_line,first_col,last_col
word_len = last_col - first_col + 1
wrd = Substr(line,first_col,word_len)
upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
lower = 'abcdefghijklmnopqrstuvwxyz'
first = Verify(wrd,upper||lower,'M')/* First alphabetic */
If first < 1 Then
first = 1
Endif
wrd = Substr(wrd,first)
last = Verify(wrd,upper||lower) - 1/* Last alphabetic */
If last < 1 Then
last = word_len - first + 1
Endif
wrd = Substr(wrd,1,last) /* Alphabetic word */
If Verify(wrd,upper) = 0 Then /* All uppercase */
Call plowercase() /* -> Capitalise */
.cursorx = first_col + first - 1
mark_block
Call puppercase()
Elseif Verify(wrd,lower) = 0 Then /* All lowercase */
Call puppercase() /* -> uppercase */
Else /* Mixed case */
Call plowercase() /* -> lowercase */
Endif
Call prestore_mark(save_mark)