/******
*   convert word to lower[UPPER] case SPELLcheck or FIND next occurance
*
*******/
call addlib('rexxreqtools.library',0,-30)

parse upper arg case
address value address() ; 'rv !edinfo!'

Line = edinfo.current
cPos = edinfo.x
Word = ''

SepChar = ' +-*/%|&~=><^,;:()."''\1234567890!@#$_{}?`[]' || '0a'x

FIND_WORD:
 do Idx = cPos by -1 to 2 until verify(substr(Line,Idx-1,1),SepChar) = 0
   'cl'                               /* move Backward to SepChr  */
 end ; if Idx ~= 1 then 'cr'          /* Fwd to first chr of word */

 do Idy = Idx until verify(substr(Line,Idy+1,1),SepChar) = 0
   Word = Word || substr(Line,Idy,1)  /* fwd to SepChar, save each letter */
 end

FIND:
 if case = 'FIND'  then do            /* find next "Word" */
   'uc'
   'f`'Word'`'
    exit
 end

BFIND:
 if case = 'BFIND'  then do           /* find previous "Word" */
   'uc'
   'bf`'Word'`'
    exit
 end 

SPELL: 
 if case = 'SPELL' then do            /* send "Word" to AZspell */
    if length(Word) > 3 then DO
       TempFile = 't:Spell.tmp'
       address command
         'echo >'TempFile Word 'abc'
         'run azspell' TempFile
       END
    exit
 end

UPPER_lower:
 if case = 'UPPER' then Word = upper(WORD)
 else Word = translate(Word,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
   'e``'Word'`'
    length(Word) 'dc'
 exit
