write a double type variable with File.Write()


Recommended Posts

I'm just curious.

Before I never was able to write a double variable to a file without convert to string using file.write() such as

Global myVar = 8

File.Write(OpenFile, "myVar =," + myVar)

Would give me an error. But now I'm using DF16.3 and the code above will work just fine.  

Link to comment
Share on other sites

Nothing has changed.  When concatenating values with +, the data type of the first item in the list determines the overall type.  And DAQFactory will automatically convert a number to a string when needed, but not the other way.  So:

myVar + " = myVar"

will generate an error, but:

"myVar = " + myVar

won't.  The best thing is to use doubleToStr(), but I still often use a trick even when I want the number first, for example:

"" + myVar + " = myVar"

won't generate an error because the first item is a string, albeit an empty one.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.