View Full Version : Filter source and find with in using macros
Matt.Tyler
06-17-2002, 12:29 PM
I need to search for a specific item (a name of a BEGSR) entry. I would like to limit the search to only those lines that are BEGSR lines. What function would work the best. P.S. i need to do this inside a macro. -- Thanks, Matt Tyler mattt@wincofoods.com
Guest.Visitor
06-17-2002, 02:44 PM
I doth quote yon "Matt Tyler" <mattt@wincofoods.com> in saying: > I need to search for a specific item (a name of a BEGSR) entry. > > I would like to limit the search to only those lines that are BEGSR > lines. > > What function would work the best. > > P.S. i need to do this inside a macro. > > -- > Thanks, > Matt Tyler > mattt@wincofoods.com > This should be fairly easy to do. I'd think you'd use the ZOOM function. I typically search for subroutine references by pressing Ctrl-I (zoom), then specifying "BEGSR|EXSR|CAS[ |EQ|LE|LT|GE|GT]" as the string to select. This will find all statements with BEGSR, EXSR, or CASxx opcodes. (I don't think I've EVER used anything but CASEQ or CAS...). As to how you'd get ZOOM to use that search in a macro... ? Somebody else?
batthish@ca.ibm.com
06-19-2002, 05:23 AM
Hi Matt, I don't know if this will do exactly what you need, but if you look at the profile RPGLE400.LX you will see the following menu bar item: 'SET ACTIONBAR.LP_VIEW.S~how.Su~broutines ;INCLUDE SUBROUTINE;SET EXCLUDE PROCEDURE;SET VIEWNAME Subroutines' This menu item filters out all lines except for BEGSR and ENDSR lines. So if you added the following to your macro, you would get only those lines from which to search: 'INCLUDE SUBROUTINE' 'SET EXCLUDE PROCEDURE' How does this work? Each line in the editor has one or more classes (use QUERY CLASS) defined for it. When the parser goes through the document, it classifies lines. Now if you query the classes on the BEGSR lines you will see that the classes are: SPACE SUBROUTINE And if you query the classes on the ENDSR lines, you will see that the classes are: SPACE SUBROUTINE ALL.SEL So if you wanted your macro to ignore the ENDSR lines as well, you would add the following line after the ones I gave you above: 'SET EXCLUDE ALL.SEL' Now if you did a search, only the visible (included) lines are searched. Hope this helps! Violaine Batthish CODE Project Lead Toronto Lab, IBM Canada
Matt.Tyler
06-19-2002, 01:27 PM
Violaine, I did try the code you suggested but it was not much different than using the " 'all find any ' TEXT ". Someone suggested that I use the ZOOM.lx. I can fnid the source line I am looking for, but for some reason I cannot get the cursor to position to that line. If I try the script manually, the editor does as I expect and I have the view I am looking for (the cursor is on the BEGSR statement). When I run my script that does not happen. The sursor stays at the line I initiated the macro from and redisplays that area of the source again. Also, I cannot seem to get the cursor to return to the edit area from the command line. Below I am attaching the macro I created. My goal is to create a prefix command "G" to "GOTO" a subroutine named on an EXSR statement and then return to where the original goto occurred. For now I would be happy to have it just position to the BEGSR statement of the named subroutine and position the cursor to that line. ---------- CODE - START ---------- /* GOTOSUBR.LX */ /* goto to a subroutine */ /* Debug options */ trace R 'extract doctype' 'query doctype' 'query classes' /* default setup */ 'set focus.row 4' spaces= ' ' /* Set up for specific source types */ select /* ILE RPG IV types */ when (doctype = 'IRP') | (doctype = 'VRP') then do ps_opcode = 26 ps_opcodelen = 10 ps_factor1 = 12 ps_factor2 = 36 ps_Faclen = 14 end /* OPM RPG/400 (RPGIII) types */ when (doctype = 'RPG') then do ps_opcode = 28 ps_opcodelen = 5 ps_factor1 = 18 ps_factor2 = 33 ps_Faclen = 14 end Otherwise exit end 'extract rawtext ' rawtext opcode = substr(rawtext,ps_opcode,ps_opcodelen) factor2 = substr(rawtext,ps_factor2,ps_faclen) 'msg' opcode '-' factor2 ': ' ps_opcode ': ' ps_factor2 /* Only continue if opcode is EXSR */ if opcode <> 'EXSR' then DO 'msg Error: cursor not on EXSR operation.' END else DO findstring = factor2 || 'BEGSR' 'all find any ' findstring 'query element' 'query linenumber' 'focus' 'all' 'query cursorrow' exit END /* e-if opcode=exsr */ ---------- CODE - END ---------- "Violaine Batthish" <batthish@ca.ibm.com> wrote in message news:aeq0c0$n1e$1@news.boulder.ibm.com... > Hi Matt, > > I don't know if this will do exactly what you need, but if you look at the > profile RPGLE400.LX you will see the following menu bar item: > 'SET ACTIONBAR.LP_VIEW.S~how.Su~broutines ;INCLUDE SUBROUTINE;SET EXCLUDE > PROCEDURE;SET VIEWNAME Subroutines' > > This menu item filters out all lines except for BEGSR and ENDSR lines. So > if you added the following to your macro, you would get only those lines > from which to search: > 'INCLUDE SUBROUTINE' > 'SET EXCLUDE PROCEDURE' > > How does this work? Each line in the editor has one or more classes (use > QUERY CLASS) defined for it. When the parser goes through the document, > it classifies lines. > Now if you query the classes on the BEGSR lines you will see that the > classes are: > SPACE SUBROUTINE > And if you query the classes on the ENDSR lines, you will see that the > classes are: > SPACE SUBROUTINE ALL.SEL > So if you wanted your macro to ignore the ENDSR lines as well, you would > add the following line after the ones I gave you above: > 'SET EXCLUDE ALL.SEL' > > Now if you did a search, only the visible (included) lines are searched. > Hope this helps! > > Violaine Batthish > CODE Project Lead > Toronto Lab, IBM Canada
batthish@ca.ibm.com
06-20-2002, 04:58 AM
Hi Matt, Your macro is almost there. If you change the line: 'all find any ' findstring to 'find any ' findstring You will see that the cursor will automatically get positioned to the lien You should then remove the line: 'all' from your macro. As for returning to the edit window from the command line, I don't think you can do that from within a macro, but you needn't worry as invoking the macro from a menu option, a hot key or the prefix area would not do this. May I also suggest rather than a prefix command, how about a hot key? Ctrl-G is not defined for either ILE RPG or OPM RPG so you could add the following to the profiles: 'SET ACTION.C-G MACRO GOTO' Hope this helps! Violaine Batthish CODE Project Lead Toronto Lab, IBM Canada
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.