NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting a Step

I am new to TestStand 2014, so your patience is appreciated Smiley Happy.

 

I am trying to create a sequence that allows the user to drag a custom step onto the Steps window. This will launch a custom form that they can use to enter some info, but it also has a Cancel button on it. If they press Cancel, I want it to not add the step that they are adding. In other words, cancel not only the custom form, but also cancel the drag and drop of the step. It should not show up in the Steps.

 

What I've done is create a .NET assembly with the form and all that works fine. I then created a custom step type in TestStand. I added a new edit Substep to it and gave it the name OnNewStep that calls my .NET assembly. It passes the sequence context in and works fine.

When I drag an drop a new step of this type, it behaves as expected. That is, it opens the form and if I press OK, it does what it should (adds a new Local property). But it's when I press Cancel, it still adds the step. I noticed that the step is already added when the form opens, so I thought I could just delete it in the C# code if the user cancels. However, I am unable to figure out how to do this.

 

I tried using the SequenceContext.Sequence.DeleteStep and .RemoveStep, but neither of them seems to work. I am able to capture that steps info (index, group, unique id), but when it tries to delete it, I keep getting errors like "You must increment the change count of the edited file" or others that I fail to remember at the moment.

 

Can anyone please suggest a way to accomplish this or provide any other help that I can use?

 

Regards,
Scott

0 Kudos
Message 1 of 4
(850 Views)

You said that the step is already added when the form opens. Have you tried waiting to actually add the step until after the user clicks "OK?" Then you won't have to functionally delete the step if they hit "Cancel." You could give them the form to get the info for the new Local property, and then if they hit "OK" you can add the step. If they don't hit OK, you don't have to delete the step because you haven't added it yet.

 

You be having a problem with deleting the step while you're trying to edit it. Another idea would be to set the step to be "skipped" until your form closes.  Then you could go back and "delete" the step. Right click the step >> Run mode >> Skip to see the option manually.

Christine B
Technical Support Engineer
National Instruments
0 Kudos
Message 2 of 4
(805 Views)

I like the idea of waiting to add it, but the problem is that I'm not sure I can set the order.  When I click and drag it to the steps, I see it appear in the step and then my form opens, so it's as if TestStand is adding it and then opening my form.

 

I will look into skipping the step.  Thanks for the tip!

 

Maybe I should just take the Cancel button off the form...

 

 

0 Kudos
Message 3 of 4
(771 Views)

Update (the project was shelved for a while):

 

I am using this bit of code that starts to do the trick:

 

int index = sequenceContext.Step.StepIndex;
StepGroups stepGroup = sequenceContext.StepGroup;
sequenceContext.Sequence.DeleteStep(index, stepGroup);

It runs fine, and no C# errors immediately occur.  However, once Visual Studio hands control back to TestStand I get this error:

ScottTE_0-1614108963330.png

 

I found this topic from several years ago:

TestStand Error -17300 while deleting a step that mentions the same problem in TS 2010.  So has this been corrected?  Is there another work around other than disabling the step in the designer? 

 

If the error is caused by the engine trying to select the deleted step, is it possible to assign focus to somewhere else (maybe the step group header) so that it doesn't try to select a non-existent step?  Maybe it could refresh the sequence window, thereby letting the engine "reset" its view or something?

 

I'm just trying to think of a way to present a more user friendly experience if they cancel other than disabling the step.

 

Thanks and kind regards,

Scott

 

0 Kudos
Message 4 of 4
(99 Views)