11-16-2005 03:23 AM
11-16-2005 05:02 AM
Hello Moos,
In the context of a Dataplugin the DIAdem specific function are not available. Did you download the helpfile for DataPlugin developers ? You definitely should. In the helpfile you will find all function which are available in addition to the VBScript runtime specific function.
Back to your question : If you have "Error=5" what you could do is split up the string into two parts, the parameter name and the value. Use Split to do this. Split splits a given string into token separated by a delimiter you can define. As a result you get an array of tokens. In this case you would get "error" in the first array element and "5" in the second. In a second step you can use ParseString (please refer to the DataPlugin OLH) to read the number from the "5" string. If the string is simple as "5" you could also use "Clng" which is a built in VbScript function. Still ParseString is more reliable when it comes to values like "5.34E04"
Please ask if you have further questions
Andreas
11-16-2005 07:01 AM
11-16-2005 09:33 AM
11-16-2005 09:55 AM
Hello Andreas,
thank you for your help. But I still can't go on.
With your proposal 'Split' I got the values with a point between. I use GetNextLine and than I split the line by my keywords.
MyScale = "10.1 " ' a point
MyScale = CDbl(MyScale)
Call MsgBox (MyScale) ' here I see 101
But with a comma I could use it for further calculations
MyScale = "10,1 " ' a comma
MyScale = CDbl(MyScale)
Call MsgBox (MyScale) ' here I see 10,1 and I can do calculations with it.
But I only get the string with a point between (because in the file I take the value out, it is also written with a point)! And I want to change it to a comma.
11-16-2005 10:14 AM
Moos,
because of this problem I mentioned ParseString. What you want to do is use the string which contains "10.1" and parse it with ParseString :
dValue = File.Formatter.ParseString(string, eR64)
This gives you 10.1 assuming that you have set the decimal point to "." Use File.Formatter.DecimalPoint = "." to do this before you call ParseString. The VBScript function CDbl uses the Windows system settings to convert a string to a numeric value. This behaviour makes it more or less unusable for your purpose.
Hope this helps
Andreas
11-16-2005 10:44 AM
Sorry, I think I still didn't get you. I don't understand how to use File.Formatter.
My configuration file looks like that:
....
scale=1000.0
offset=0.0
unit=V
.....
My data plugin looks like that:
....
Set MyCfgFile = Openfile("configurationfile.cfg") ' a second file to work with
MyCfgFile.Formatter.DecimalPoint = "." ' is this right?????
....
MyChnComment = MyCfgFile.GetNextLine
MySplit = Split(MyChnComment, "scale=", -1, 1)
MyScale = MySplit(1)
MyScale = CDbl(MyScale)
MsgBox (MyScale) ' it shows me also 10000 (and not 1000,0 or 1000.0)
...
11-16-2005 10:56 AM
Moos, Sorry for double posting. Here is what I meant to send : Its CDbl which creates the problem. Please do not use CDbl, use ParseString instead. This is what you do : MyChnComment = MyCfgFile.GetNextLine This is what you should do : File.Formatter.Decimalpoint = "." MyChnComment = MyCfgFile.GetNextLine |
Please let me know how this works
Andreas
11-17-2005 02:30 AM
Hello Andreas,
it works!!! 🙂 Thank you very much for your help.
Moos