NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Jump to the correct location in a custom editor.

Solved!
Go to solution

I want to implement ‘find’ functionality in a custom editor.

 

I am using SearchFiles to get the SearchResults, then iterating over the SearchMatches in a for loop.

This works fine and gives me the PropertyPath for each match

SearchResults searchResults = TestStand.SequenceContext.Engine.SearchFiles(strSearchString, intSearchOptions, intFilterOptions, intElementsToSearch, strLimitToAdaptersAry, strLimitToNamedPropsAry, strLimitToPropsOfNamedTypesAry, m_PropertyObjectOpenFilesToSearchAry, strDirectoriesAndFilePathsAry);

if (searchResults.IsComplete(true, true))

{

    for (int intCounter = 0; intCounter < searchResults.NumMatches; intCounter++)

    {

         SearchMatch searchMatch = searchResults.GetMatch(intCounter);

         int intMatchElement = 0;

         int intMatchStart = 0;

         int intMatchLength = 0;

         searchMatch.GetLocation(out intMatchElement, out intMatchStart, out intMatchLength);

         string strPropertyPath = searchMatch.GetPropertyPath(true);

         Main.Current.AddLineToResults(strPropertyPath);

    }

}

 

Examples of PropertyPath ;

                Seq["MainSequence"].Main["Statement"].TS.PostExpr

                Seq["MainSequence"].Main["           Get article information"].SourceCode

 

Now, I want to have the same behavior as in de default TestStand Editor, using the property path information to jump to the location in the sequence.

I have tried this with the following code.

When the line ‘Location location = locations.AddFileLocation(propertyObjectFile, strLocation)’ is executed, the execution jumps to the procedure WnProc(ref Message ms) and NEVER returns to complete the other instructions?

 

        private void lvwResult_SelectedIndexChanged(object sender, EventArgs e)

        {

            string strMessage = string.Empty;

            Locations locations = m_Engine.NewLocations();

            string strLocation = lvwResult.SelectedItems[0].Text.ToString();

            PropertyObjectFile propertyObjectFile = m_AxSequenceFileViewMgr.SequenceFile.AsPropertyObjectFile();

            Location location = locations.AddFileLocation(propertyObjectFile, strLocation);

            locations.GotoLocation(GotoLocationOptions.GotoLocationOption_NoOptions);

            if (!m_Locations.LocationFound)

                strMessage = m_Locations.LocationNotFoundMessage;

            m_AxApplicationMgr.RefreshAllViewMgrs();

        }

 

I suppose that it is possible to jump to correct location in the sequence with code as listed above. What am I doing wrong here?

Any help is highly appreciated.

 

Best regards

 

Patrick

 

0 Kudos
Message 1 of 6
(3,422 Views)

The problem seems to be a wrong 'lookupstring'!

 

The help files says:

 

lookupString As String

[In] Pass a subproperty of the file parameter. This method sets the Location.PropertyPath property of the new Location to the lookup string to lookupString from file. This method also sets as many properties of the new Location as this method can obtain from the object you pass.

 

Does anyone know the correct syntax for the lookupstring. Now, I am using the PropertyPath, but this seems to be wrong or not in the correct format.

 

Patrick

 

0 Kudos
Message 2 of 6
(3,419 Views)

 

Consider following lookupstring as an example;

 

Seq["MainSequence"].Main["           Get article information"].SourceCode

 

When this string is passed as lookupstring in the method locations.AddFileLocation, a error occurs 'Unknown variable or property name 'Seq'.

So, it seems to be 'Seq' is wrong, but what should it be?

 

When a 'Find' is done in the default TestStand Editor for the same sequence, the syntax of location showed in the Find Results pane is exactly the same.

 

When double clicked in the default TestStand Editor, it jumps to the correct step in the sequence.

 

Does anyone know what the correct syntax is for the lookupstring?

I am not able to figure out with the information in the 'Help', what it should be...

 

Best regards.

0 Kudos
Message 3 of 6
(3,401 Views)

See my latest post.

0 Kudos
Message 4 of 6
(3,386 Views)
Solution
Accepted by topic author ccds

@ccds wrote:

 

Consider following lookupstring as an example;

 

Seq["MainSequence"].Main["           Get article information"].SourceCode

 

When this string is passed as lookupstring in the method locations.AddFileLocation, a error occurs 'Unknown variable or property name 'Seq'.

So, it seems to be 'Seq' is wrong, but what should it be?

 

When a 'Find' is done in the default TestStand Editor for the same sequence, the syntax of location showed in the Find Results pane is exactly the same.

 

When double clicked in the default TestStand Editor, it jumps to the correct step in the sequence.

 

Does anyone know what the correct syntax is for the lookupstring?

I am not able to figure out with the information in the 'Help', what it should be...

 

Best regards.


I think you need to prefix the string with "Data." so basically "Data.Seq["MainSequence"].Main["           Get article information"].SourceCode".

 

-Doug

0 Kudos
Message 5 of 6
(3,382 Views)

Thanks a lot Doug,

 

Indeed adding “Data.” In front of the string did the trick!

0 Kudos
Message 6 of 6
(3,373 Views)