Guidance
指路人
g.yi.org
Software / Reginald / Examples / macro.rex

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
/* Create a new script */
ERROR = editopendoc()
/* Check for an error */
IF ERROR \== "" THEN DO
	SAY ERROR
	RETURN
END

/* Display the name of the script */
SAY editgetdoc()

/* Insert a few lines of text */
ERROR = editselect(,, "/* This is a test */" || '0D'x || "SAY 'Line 1'" || '0D'x || "SAY 'Line 2'" || '0D'x || "str = '   DO'", 'TEXT')
IF error == "" THEN RETURN

/* Insert another line of text */
ERROR = editselect(,, '0D'x || "   END", 'TEXT')
IF ERROR == "" THEN RETURN

/* Insert 3 lines of text using a compound variable.
 * Text inserted this way (rather than the above)
 * is not "undo-able".
 */
myvar.0 = 3
myvar.1 = 'Compound line 1'
myvar.2 = 'Compound line 2'
myvar.3 = 'Compound line 3'
ERROR = editselect(,, 'MyVar')
IF ERROR \== "" THEN SAY "Success"

/* Get the text in line 1, and put it in variable 'MyVar' */
ERROR = editgettext('MyVar', '1 1', '1 -1')
IF ERROR \== "" THEN SAY ERROR
ELSE DO
   SAY "Read" myvar.0 "lines"
   SAY myvar.1
END

/* Get the text in line 2, starting a 6th char, and go until
 * line 3, third char.
 */
ERROR = editgettext('MyVar', '2 6', '3 3')
IF ERROR \== "" THEN SAY ERROR
ELSE DO
   SAY "Read" myvar.0 "lines"
   SAY myvar.1
   SAY myvar.2
END

/* Get all of the text, and put it in MyVar */
ERROR = editgettext('MyVar', '1 1', '-1 -1')
IF ERROR \== "" THEN SAY ERROR
ELSE DO
   SAY "Read" myvar.0 "lines"
   DO i = 1 TO myvar.0
      SAY myvar.i
   END
END









/* Move cursor position to first non-blank on current line */
SAY editmove('HOME')

/* Move cursor position to beginning of current line */
SAY editmove()

/* Move cursor position down one line */
SAY editmove('DOWN')

/* Move cursor position up one line */
SAY editmove('UP')

/* Move cursor position to end of the word */
SAY editmove('RWORD')

/* Move cursor position to beginning of the word */
SAY editmove('LWORD')











/* Toggle an unnamed bookmark on current line */
SAY editsetflag('UNNAME', 2)

/* Set an error indicator on current line */
SAY editsetflag()

/* Move cursor position up one line */
SAY editmove('UP')

/* Set an error indicator on current line */
SAY editsetflag()

/* Find the first line with an error indication */
SAY editfindflag('HOME|ERROR')

/* Test if current line has an error indication */
SAY editfindflag('ERROR')

/* Find next line with an error indication */
SAY editfindflag('UP|ERROR')













/* Get the text cursor's current position --
 * line number, and character number within
 * that line.
 */
SAY editselect()

/* Set the text cursor's position to first
 * character upon the first line, and remove
 * any selection.
 */
SAY editselect('1 1', '1 1')

/* Set the text cursor's position to the
 * end of the file, and remove any selection.
 */
SAY editselect('-1 -1', '-1 -1')

/* Select all the text upon the first line,
 * and set the cursor to the end of the
 * line.
 */
SAY editselect('1 1', '1 -1')

/* Replace the above text with the string
 * "Line 1" || '0D'X || "Line 2"
 *
 * NOTE: You can embed line breaks in the
 * inserted text with a '0D'X.
 */
SAY editselect(, , "Line 1" || '0D'x || "Line 2", 'TEXT')

/* Select all the text upon the second line,
 * and delete it, then set the cursor upon
 * the start of the second line.
 */
SAY editselect('2 1', '2 -1', "")














/* Find any instances of 'do' in the current script,
 * but only after the current position.
 */
DO UNTIL err = ""
err = editfind('do')
SAY err
END

/* Find all instances of 'do' in the current script,
 * starting at the current position.
 */
DO UNTIL err = ""
err = editfind('do', 'WRAP')
SAY err
END

/* Find all instances of 'do' in the current script,
 * and match the whole word.
 */
DO UNTIL err = ""
err = editfind('do', 'WORD|WRAP')
SAY err
END















/* Create a new script */
ERROR = editopendoc()
/* Check for an error */
IF ERROR \== "" THEN SAY ERROR
/* Display the name of the script */
ELSE SAY editgetdoc()

/* Create a new script, and close the window
 * when this script ends.
 */
ERROR = editopendoc(, 1)
IF ERROR \== "" THEN SAY ERROR
ELSE SAY editgetdoc()

/* Load a script named "test.rex" in the
 * current directory.
 */
ERROR = editopendoc("test.rex")
IF ERROR \== "" THEN SAY ERROR
ELSE SAY editgetdoc()

/* Load a script named "C:\test.rex" */
ERROR = editopendoc("c:\test.rex")
IF ERROR \== "" THEN SAY ERROR
ELSE SAY editgetdoc()

/* Present the load file dialog, and
 * load that script.
 */
ERROR = editopendoc("")
IF ERROR \== "" THEN SAY ERROR
ELSE SAY editgetdoc()
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Mon 2017-7-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-18 23:35:09