home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
wp
/
casechng.zip
/
CASECHNG.PF2
Wrap
Text File
|
1990-01-31
|
5KB
|
175 lines
' CASECHNG.PF2 : Change Case For Block Of Text
'
' Currently processes one character at a time using WPGET to get
' character and KEYS LOOK to put case-changed character. WPGET always
' returns special characters currently (an error reported to Informix)
' and WPPUT always inserts text - can't currently overwrite existing
' text (this shortcoming has also been reported to Informix). I'm
' sure the process can be improved once the two problems are corrected.
'
' Jon Haney 12/21/89
global move_cursor(),change_case()
public sec_1,pag_1,lin_1,col_1 'Starting section, page, line, column
public sec_2,pag_2,lin_2,col_2 'Ending section, page, line, column
public cur_1,cur1_lin,cur1_col 'Starting cursor position for current screen
public cur_2,cur2_lin,cur2_col 'Ending cursor position for current screen
public tx 'Current text char
public in_char 'Input character from user
public ins_mode 'Insert mode (0=off,1=on)
public change_up '<U> = change to upper case, <L> = lower
smartpeek $_cpos cur_1
cur1_lin = int(cur_1/256)
cur1_col = mod(cur_1,256)
locate cur1_lin cur1_col 2
in_char = 0
while in_char <> "Enter"
screen clear box 22 1 23 80 15 0 no-border
screen print 22 1 15 0 "Position cursor on FIRST character of block and press Enter"
key name inchar in_char
if in_char <> "Enter"
move_cursor() 'Move cursor if necessary
end if
end while
sec_1 = wpinfo(1)
pag_1 = wpinfo(2)
lin_1 = wpinfo(3)
col_1 = wpinfo(4)
smartpeek $_cpos cur_2
cur2_lin = int(cur_2/256)
cur2_col = mod(cur_2,256)
locate cur2_lin cur2_col 2
in_char = 0
while in_char <> "Enter"
screen clear box 22 1 23 80 15 0 no-border
screen print 22 1 15 0 "Position cursor on LAST character of block and press Enter"
key name inchar in_char
if in_char <> "Enter"
move_cursor()
end if
end while
change_up = 0
while NOT(change_up=="U" or change_up=="L")
screen clear box 22 1 23 80 15 0 no-border
screen print 22 1 15 0 "All <U>pper case or all <L>ower case ?"
key name inchar change_up
end while
repaint off
sec_2 = wpinfo(1)
pag_2 = wpinfo(2)
lin_2 = wpinfo(3)
col_2 = wpinfo(4)
evaluate("document goto location \
s"|str(sec_1)|"p"|str(pag_1)|"l"|str(lin_1)|"c"|str(col_1))
smartpeek $_ins ins_mode 'save current insert_mode status
smartpoke $_ins false 'set insert_mode off
while ins_mode <> 2 'ins_mode will always not equal 2
if (sec_1=sec_2 and pag_1=pag_2 and lin_1=lin_2 and col_1=col_2)
change_case()
exit while 'exit while loop
end if
change_case()
sec_1 = wpinfo(1)
pag_1 = wpinfo(2)
lin_1 = wpinfo(3)
col_1 = wpinfo(4)
end while
smartpoke $_ins ins_mode 'restore initial insert_mode
repaint
end
function move_cursor() 'allows you to move cursor to mark block
case ' (NOTE: I don't highlight the block
when (in_char = "Right") ' with current implementation)
suspend
keys Right,F8
when (in_char = "Left")
suspend
keys Left,F8
when (in_char = "Up")
suspend
keys Up,F8
when (in_char = "Down")
suspend
keys Down,F8
when (in_char = "PgUp")
suspend
keys PgUp,F8
when (in_char = "PgDn")
suspend
keys PgDn,F8
when (in_char = "^Right")
suspend
keys ^Right,F8
when (in_char = "^Left")
suspend
keys ^Left,F8
when (in_char = "Home")
suspend
keys Home,F8
when (in_char = "End")
suspend
keys End,F8
when (in_char = "^Home")
suspend
keys ^Home,F8
when (in_char = "^End")
suspend
keys ^End,F8
end case
return
end function
function change_case()
tx = left(wpget(1,0),2) 'get character of text, or special char(s)
'"%" returns more than "%%" so limit to 2
case
when (tx=" ") 'skip over special characters
suspend ' (AND UNDOCUMENTED characters that
keys Right,F8 ' cause the KEYS LOOK command to error)
when (tx="""")
suspend
keys Right,F8
when (tx="%t")
suspend
keys Tab,F8
when (tx="%p")
suspend
keys Right,F8
when (tx="%-")
suspend
keys Right,F8
when (tx="%%")
suspend
keys "%",F8
when (tx=",")
suspend
keys Right,F8
when (tx="'")
suspend
keys Right,F8
otherwise 'change case of text characters
if change_up=="U"
tx = upper(tx)
else
tx = lower(tx)
end if
key define "#1000" tx
suspend
keys look,#1000,F8 'overwrite existing text character
key remove "#1000" ' with case-changed text character
end case
return
end