substring error
Submitted by Saturday, 26 August, 2006 - 02:16
on
Hello Everyone,
I am creating a macro, using hypersearch_results_to_buffer as a starting point. I have modified the macro so far so that the path is not included. Now, I would like to strip out the line number. Using the following code:
traverseTree(javax.swing.tree.DefaultMutableTreeNode node, StringBuffer results){
if (node.getUserObject() instanceof org.gjt.sp.jedit.search.HyperSearchFileNode)
{
path = node.getUserObject().path;
match = node.getFirstChild();
while(match != null)
{
text = match.getUserObject().str;
results.append(text + "\n");
match = match.getNextSibling();
I get results like:
1770: material CabinetBase
1792: material CabinetBase_Panel_01.jpg.001
So I try to modify the block to:
text = match.getUserObject().str;
myStrLoc = (text.indexOf(":")+1);
text = text.subString(myStrLoc);
results.append(text + "\n");
match = match.getNextSibling();
However, every time I try to run the macro, I get the following error:
Sourced file: C:\Program Files\jEdit\macros\Misc\HyperSearch_Results_to_Buffer2.bsh : Error in method invocation: Method subString( int ) not found in class'java.lang.String' : at Line: 37 : in file: C:\Program Files\jEdit\macros\Misc\HyperSearch_Results_to_Buffer2.bsh : text .subString ( myStrLoc )
Called from method: writeHypersearchResultsToBuffer : at Line: 81 : in file: C:\Program Files\jEdit\macros\Misc\HyperSearch_Results_to_Buffer2.bsh : writeHypersearchResultsToBuffer ( view )
I have tried using text = text.subString(1); and text = text.subString(1,8);
...but I get the same results.
What am I missing?? Thanks in advance for your help!!
I am creating a macro, using hypersearch_results_to_buffer as a starting point. I have modified the macro so far so that the path is not included. Now, I would like to strip out the line number. Using the following code:
traverseTree(javax.swing.tree.DefaultMutableTreeNode node, StringBuffer results){
if (node.getUserObject() instanceof org.gjt.sp.jedit.search.HyperSearchFileNode)
{
path = node.getUserObject().path;
match = node.getFirstChild();
while(match != null)
{
text = match.getUserObject().str;
results.append(text + "\n");
match = match.getNextSibling();
I get results like:
1770: material CabinetBase
1792: material CabinetBase_Panel_01.jpg.001
So I try to modify the block to:
text = match.getUserObject().str;
myStrLoc = (text.indexOf(":")+1);
text = text.subString(myStrLoc);
results.append(text + "\n");
match = match.getNextSibling();
However, every time I try to run the macro, I get the following error:
Sourced file: C:\Program Files\jEdit\macros\Misc\HyperSearch_Results_to_Buffer2.bsh : Error in method invocation: Method subString( int ) not found in class'java.lang.String' : at Line: 37 : in file: C:\Program Files\jEdit\macros\Misc\HyperSearch_Results_to_Buffer2.bsh : text .subString ( myStrLoc )
Called from method: writeHypersearchResultsToBuffer : at Line: 81 : in file: C:\Program Files\jEdit\macros\Misc\HyperSearch_Results_to_Buffer2.bsh : writeHypersearchResultsToBuffer ( view )
I have tried using text = text.subString(1); and text = text.subString(1,8);
...but I get the same results.
What am I missing?? Thanks in advance for your help!!