Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / RPC macro

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. 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

/* Raise ERROR for any problems with RPC macro functions */
rexxederr = "ERROR"

DO
	PATH = editgetdoc()

	/* Get current selection */
	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 ????
Message2.
#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 • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0