| Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 | 1. RPC macro #10654 Posted by: Michael S 2007-06-11 23:02:21 Last edited by: Michael S 2007-06-11 23:04:59 (Total edited 2 times) | Am trying to write a simple RPC macro that will translate selected text in a file to lowercase. Here is my attempt (most comments removed)
LIBRARY rexxgui
rexxederr = "ERROR"
DO
PATH = editgetdoc()
DO
editgettext("temp_name")
CATCH ERROR
guisay("Mark text for conversion to lowercase first")
RETURN
END
l_case = 'abcdefghijklmnopqrstuvwxyzåäö'
u_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ'
temp_name.1 = TRANSLATE(temp_name.1, l_case, u_case)
editselect(,,'Temp_name')
END
CATCH ERROR
CONDITION("M")
Obviously I'm doing something wrong, because I start off with the following text /* Pull the whole file into the stem variable SOURCECODE. */ filein = 'tracelit.rex' CALL STREAM(filein, 'C', 'OPEN READ') CALL LOADTEXT('sourcecode.', filein) CALL STREAM(filein, 'C', 'CLOSE') search_arg = translate('when next_arg == ') If I mark the string "OPEN READ" and run the macro above,I get DO /* Pull the whole file into the stem variable SOURCECODE. */ filein = 'tracelit.rex' CALL STREAM(filein, 'C', '') open read CALL LOADTEXT('sourcecode.', filein) CALL STREAM(filein, 'C', 'CLOSE') search_arg = translate('when next_arg == ') tracelit_args = '/' note how the line has been split in two parts. Am I doing somethng wrong or just trying to use RPC macros for more than they were intended ???? | 2. #10656 Posted by: Jeff Glatt 2007-06-12 05:55:11 Last edited by: Jeff Glatt 2007-06-29 05:30:23 (Total edited 1 time) | Unless you use the 'TEXT' option, then it assumed that you're inserting full (new) lines into the text. That's why your inserted text got put on a new line. You need to use 'TEXT' to insert text within a line.
But are you aware that RPC already has a command to lower case the selection? Bring up "Options -> Keyboard shortcuts". Look under the "Command" category, and toward the bottom of the list, you'll see "Lower case selection". Just assign some keyboard shortcut to it, and there you go. | Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 |
|
|