03-03-2010 08:33 AM
Hello.
I have problem with replacing values in text channels and I can't find solution.
I have couple of channels filled with only 2 values: OK and NOK. How can I replace these values with for example 1 for OK and 0 for NOK ?
This replacement is needed for a chart drawing. With current values I can't draw the chart because Diadem don't accept text values as a scale.
Thanks in advance 🙂
Solved! Go to Solution.
03-04-2010 02:16 AM
Hello,
For programming, Diadem uses Visual Basic Scripting, therefore in the script window you can create two new channels, parse the ones you currently have and change the text values to numeric. There are plenty of examples and tutorials on VBS on the web, surely you could find also text parser.
You could get a clue here:
http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/725001647731
http://www.computing.net/answers/programming/vbscript-help-parsing-a-text-file/14327.html
Diadem Help is useful on presenting how to create new channel
Regards
Emil
03-04-2010 03:35 AM
Hi
What do You mean "parse the ones you currently have and change the text values to numeric" ? When I import my data as a numbers all results are "NoValue". Imported data must be marked as a text value.
I looked in Diadem VBS Help but I didn't find simple "find & replace" function that works. Under Excel VBA is quite easy to do but under Diadem it is much more complicated for me 🙂
03-04-2010 05:31 AM
Hello,
I mean that you should programatically, using VBS, go element with element through the text values, read them, compare them with OK, NOK and then programatically create new numeric channel and replaceOK with 1 and NOK with 0.
I know it is not so easy using VBS, but for example you can use the programming languages you are familiar with to open your file, parse it and replace the OK, NOK with numeric values, and then further you can generate reports in Diadem.
Emil
03-04-2010 08:29 AM
Hello Domin,
replacing a substring in a text with another text can be done with the VBS function "Replace".
Executing a function on a whole channel can be done by using ChnCalculate.
Combine the two and you get :
ChnCalculate("ch(""Statistics text"") = Replace(ch(""Statistics text""),""value"",""LLL"")")
This refers to a channel from the DIAdem example data set. The above command executes the "Replace" command for each value of the text channel "statistics text" . It replaces each occurance of "value" with "LLL".
Hope this helps
Andreas
03-04-2010 09:39 AM
Hello Domin,
Here is another easy way to solve this.
You can turn this into a Script by adding a call to the calculator:
I hope that helps, it doen't really get much easier than that. And this is very fast as well, if you have long channels.
Let me know if I can be of further assistance,
Otmar
03-08-2010 08:08 AM
Hello
The solution that Andreas suggested worked for me perfectly.
Thank You 🙂