× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 7/18/2011 11:32 AM, Paul Bailey wrote:

Are there any help pages for using Rexx with Code/400? The option of not having to cut&paste the whole source file is attractive.

Help, Editor Reference.
Help, Rexx Help.

For those following along, Rexx was originally designed to 'plug in' to
VMS, and saw a fair amount of use in Xedit scripting. So the language
itself is more or less designed to work side-by-side with another
application, to extend that application. For most IBM i people, perhaps
the closest idea to Rexx is a very sophisticated PDM user command.

The Rexx interpreter that comes with Code/400 'knows' about the editor's
inner workings. Rexx can directly set menu items, accelerator keys, and
alter many visual aspects of the editor. Rexx can also issue editor
commands (like File, Open) and perhaps most interesting to us are the
ways Rexx can manipulate the text in the editor's buffer. The advantage
to us is that rather than manually executing a series of scan/replace
cycles, we can write a single Rexx macro to do them all for us, looping
as we go.

IBM supplied a bunch of macros in the WDSC\samples directory. You can
also find some in the WDSC\macros. Use command EXTRAS ON
c:\wdsc\samples to load them. The ones in the macros directory are
already loaded.

Here is a quick example of looping through a source member to exchange
55 ITER into IF *IN55 = *on...Iter...Endif


To run it, put it in your own macro directory (I call mine macros) and
press escape to get to the command line, then EXTRAS ON c:\macros and
enter. Run the macro the same way. Escape, iter, enter. To modify the
macro, edit it (Code/400 works great!), save it and try it again.
Alt-right cursor will quickly change windows between the macro and the
RPG source.

/* iter.lx */
/* convert old style ITER to multi-line IF..ITER..ENDIF */

/* 55 ITER */
/* limitation: existing code must be upper case */
count = 0
do while 1 = 1

/* locate an ITER with an indicator - 55 ITER */
'find match (.{5})C.. ([0123456789]{2}) {14}ITER'
if rc = 1 then do
leave
end

count = count + 1
'extract content'

/* break out the fields */
parse var content spec indicator opcode

/* delete the current line */
'delete'
'prev'

/* write some new lines */
line1 = copies(" ",5) || spec || copies(" ",19) || "IF *IN" ||
indicator || " = *ON"
line2 = copies(" ",5) || spec || copies(" ",19) || strip(opcode,L)
line3 = copies(" ",5) || spec || copies(" ",19) || "ENDIF"
'insert'
'insert' line1
'insert' line2
'insert' line3
'insert'

end


/* N55 ITER */
/* limitation: existing code must be upper case */
do while 1 = 1

/* locate an ITER with a NOT indicator - N55 ITER */
'find match (.{5})C..N([0123456789]{2}) {14}ITER'
if rc = 1 then do
msg "Done! " || count || " found."
return
end

count = count + 1
'extract content'

/* break out the fields */
parse var content spec indicator opcode

/* delete the current line */
'delete'
'prev'

/* write some new lines */
line1 = copies(" ",5) || spec || copies(" ",19) || "IF *IN" ||
strip(indicator,L,"N") || " = *OFF"
line2 = copies(" ",5) || spec || copies(" ",19) || strip(opcode,L)
line3 = copies(" ",5) || spec || copies(" ",19) || "ENDIF"
'insert'
'insert' line1
'insert' line2
'insert' line3
'insert'

end

It needs work, but it shows the general idea.
--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.