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:
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?
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.
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.
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...
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.
there is indeed a way. Daniel was so kind to provide this link.
So Kudos to him!
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,