08-03-2023 03:40 AM
I have a batch file, that determines the mean value.
How can I now use this !mittelwert!-variable in my batch file to save/implement it in my teststand variables?
The important lines of the batch file are attached.
Solved! Go to Solution.
08-04-2023 12:12 AM
Use the Call Executable Step Type and write stdout to a variable that can be parsed
08-07-2023 01:48 AM
Thank you!
Is it also possible to determine the mean value of any IP-adress just in Teststand so that I don't need a batch file, so I need less files at the end for my program and the program is less error prone?
08-07-2023 02:17 AM
No worries 🙂
Brilliant idea, since he ping command calculates a meanvalue by itself.
So your Step Setup would look something like
The parsing of the returned string has to be accomplished somehow though. You might want to consider using a code module for this: though TestStand String should be technically sufficient, the expression needed will probably not be very intuitive.
When parsing, keep in mind, that the ping command comes localized, so parsing on different OS region settings may cause the operation to fail.
08-07-2023 03:47 AM
I stored the string of the pingtest in my standardoutput how you can see.
Then i tried with the find() function to determine the Mittelwert (it's german for mean value) but it didn't work as i wished.
Do you know how i could extract the 0 from Mittelwert = 0ms?
08-07-2023 04:45 AM
Keep it simple and stupid, don't use overly complex expressions.
Store the stdout to a local variable and use an expression step to do the parsing Find() will return the postion of "Mittelwert" within the string, from there on you can work with Right(), Left() and Split()
08-07-2023 05:38 AM
Thank you so much for your help, unfortunately i am pretty new to this program and i don't exactly know how to use the most functions properly.
I stored the Variable in Locals.Mittelwert but there is no Value when i look in to my Variables after i tested the sequence.
Then i wanted to use the mentioned expression to find the wanted string but it also didn't work.
I don't know exactly what I'm doing wrong.
08-07-2023 07:19 AM
Brilliant opportunity to learn, so I'm not giving you the solution yet the way to find out yourself 😉
Some of these steps may be merged, but for reason of simplicity, I described them seperately
1.) Store stdout in a local variable, e.g. Locals.PingResult
2.) Create a numeric variable and assign the result of the Find() operation applying Locals.PingResult
3.) Create a string variable and assign the result of the Right() operation
This is still not going to give you what you want, yet it'll help you to find out what you need. Especially if you single step through your code and watch the variable values after each operation
Recommendation:
08-07-2023 09:53 AM
I do my best to understand the functions and learn through them 🙂 So i studied all the descriptions of the string operators and that would be my suggested solution.
First the "Call Executable" pings my desired IP address and should store the text in the Locals.PingResult-string.
After that the position of the characters "Mittelwert = " is determined.
After that the position of the first number of the determined ping.
After that the position of "ms".
Afterwards the pure numeric value of the ping can be determined with these positions.
But unfortunately it fails already at the first step, because the executable does not write the text into the local variable.
Below you could see the steps i used and also the Variables i created and that the Locals.PingResult has no value.
I actually already thought that it should work like this 😞
08-08-2023 12:27 AM
Ok, so let's see
I have just placed a Call Executable in an empty seq file like this
As you can see, I have also routed stderr to a local variable to see any errors occuring
Pausing the execution after the Call Exec Step and checking the variables shows
Ping Result looks a little strange here, but hovering over shows
so the stdout has definitely returned the desired results
Can you please:
Please also feel free to attach a sample sequence file to this thread for review
Cheers
Oli