NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Menu item in Tools menu - Enable Expression

Hi All,

 

I am trying to add a custom menu item into the TestStand >> Tools menu. This menu item should be accessible only during edit-time and not while any executions are running. I want the menu item to be enabled only on the condition that the directory in which the active sequence file is present should also contain an associated file with the same name as the sequence. I tried getting the Active sequence file path with Runstate.SequenceFile.Path and Runstate.InitialSelection.SequenceFile.Path expressions but the menu item is always disabled whenever I click on the Tools menu.

 

The entire expression that I use to check whether this associated file is available or not is this:

FindFile(SearchAndReplace((Split(RunState.SequenceFile.Path,"\\")[GetNumElements(Split(RunState.SequenceFile.Path,"\\"))-1]),".seq",".ini",0,False,-1,False,0),True,"",3,1,False,False)

 

Split(RunState.SequenceFile.Path,"\\") - Splits the entire path with \\ demiliter. The output of the function is an array.

 

Split(RunState.SequenceFile.Path,"\\")[GetNumElements(Split(RunState.SequenceFile.Path,"\\"))-1] - Splits the entire path with \\ delimiter, get the number of elements in this array and indexes the last element. The last element would give the name of the sequence.

 

SearchAndReplace((Split(RunState.SequenceFile.Path,"\\")[GetNumElements(Split(RunState.SequenceFile.Path,"\\"))-1]),".seq",".ini",0,False,-1,False,0) - Searches and replaces the .seq file extension with .ini extension.

 

Finally the Find File function searches for the ini file in the same directory as the sequence.

 

If I put this same expression in a Message popup and convert the result of FindFile to True/False, the result is displayed properly based on the sequence that I put this message popup into.

 

If the expression I have used is not correct, how should the expression be?

 

Thanks,

Saranya

0 Kudos
Message 1 of 7
(5,464 Views)

Saranya,

 

I would expect teh RunState.SequenceFile in the tools menu context to be the sequence file which contains the tool sequence. You have to look for the ClientFile instead.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 7
(5,462 Views)

Hi Norbert,

 

Client Files come into picture only when there is an execution. I don't want the custom menu item to be even visible when there is an execution. I want the menu to be available only when the user is editing the sequences.

 

Thanks,

Saranya

0 Kudos
Message 3 of 7
(5,457 Views)

Saranya,

 

You are correct that the term "ClientFile" in this context was misleading. However, the sequence you configured for your tool entry is executed as interactive execution (no process model) when the user selects this tool menu entry.

 

Sadly, i haven't found a way to get the current active sequence in the editor for now...

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 7
(5,453 Views)

Thanks for trying Norbert!  I also haven't found any other method to find the active sequence.

 

I am eager to hear if this can be achieved in any other way.

 

Thanks,

Saranya

0 Kudos
Message 5 of 7
(5,450 Views)

Saranya,

 

there is indeed a way. Daniel was so kind to provide this link.

 

So Kudos to him!

Norbert

 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 7
(5,443 Views)

Thanks for the link Norbert! I did try it out and I found another mistake in the expression that I use. While trying to find the associated file with FindFile(), I have used the "useCurrentSeqDir = True" option which will not work because the current sequence is the tool menu sequence and not the sequence in Runstate.InitialSelection.SelectedFile.Path. So I modified this option to False and I added the directory to be searched for in TestStand Search directories and it worked like a charm!

 

Thanks for the help,

Saranya

0 Kudos
Message 7 of 7
(5,430 Views)