I am trying to write decimal values to a text file formatted so that there is a specific number of precision after the decimal point. I seem to be overlooking something very basic about how argDec() and Strings work and I am stuck.
Here is what I have tried so far:
function main() {
var pi=Math.PI;
var piString = new String;
var formatted = new String;
var fileout=new File('c:/pi.txt');
fileout.open(File.WriteOnly);
fileout.writeLine('pi = '+pi);
piString = pi.toString();
formatted = piString.argDec(piString,3,'e',2);
fileout.writeLine('piString = '+piString);
fileout.writeLine('formatted = '+formatted);
fileout.close();
}
This is what pi.txt looks like:
pi = 3.141592653589793
piString = 3.141592653589793
formatted = 3.141592653589793
And the message that pops up in the scripting output:
QString::arg: Argument missing: 3.141592653589793, 3.14159
Can anyone help?
Carl Helquist
Formatting Text File Output
Moderator: andrew
-
- Junior Member
- Posts: 15
- Joined: Wed Dec 03, 2008 7:12 pm
http://doc.trolltech.com/4.3/porting-qsa.html
String.argDec() This function is not available in Qt Script. Use replace() or concat() instead.
String.argDec() This function is not available in Qt Script. Use replace() or concat() instead.