If you have one sequence with local variables. Can you (best approach?) access these local variables from within a second sequence called (as a sequence call step) from within the first sequence? (Other than using station or file global variables)
Are there any issues with doing this (multi thread dangers etc)?
Add parameters to your second sequence. Pass the local variables from the first sequence to these parameters when you call the second sequence.
As long as you don't specify that the sequence call runs in a new thread, there are no multithreading issues. If the sequence call does start a new thread, be wary of passing parameters by reference (which is the default) because both the caller and callee could make changes to the variable you pass without realizing that each sequence is not necessarily the only sequence accessing the variable at a given time.
There are 3 ways you can access the local variables of the calling sequence from the callee:
1) Passing the local variables as parameters (as described by James Grey's answer). This is a simple and easy method. However, the disadvantage would be that you'll have to add to the callee as many parameters as local variables you want to access.
2) From the callee, you can access any property of the calling sequence (including local variables, file globals, parameters, step properties...) through the "RunState.Caller" property. For i.e., if the calling sequence has a local variable called "MyVariable", the propery path you would use from the callee would be "RunState.Caller.Locals.MyVariable". From the RunState.Caller property you have access to the sequence context of the calling sequence! Therefore, you could access any property of the calling sequence by using the correct property path. This second method will work when the callee is running in the same thread as the calling sequence or even in a new thread. However, it won't work if it is called in a New Execution, in which case, the RunState.Caller property doesn't exist.
3) Add an ActiveX Reference Parameter to the callee and pass the sequence context of the calling sequence (ThisContext) as the argument. In the callee, you may access any property of the calling sequence by using the API methods SetValNumber, SetValString, SetValBoolean, etc. You could use the ActiveX adapter configured as follows: - ActiveX Reference: Parameters.SeqContext (This would be the name of the parameter you added) - Automation Server: TestStand API - Object Class: PropertyObject - Action: Call Method - Method: SetValNumber (or SetValString, SetValBoolean, etc.). You'll need to give the correct path to the property you are trying to access as the lookup string. For i.e., if the calling sequence local variable is called "MyVariable", the property path would be "Locals.MyVariable" (including the double quotes). This last method will work even if the subsequence is called in a New Execution.
The best method will really depend on what you are doing as previously described.