Page 1 of 1

Formatting Text File Output

Posted: Wed Dec 03, 2008 8:35 pm
by carlhelquist
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

Posted: Fri Feb 13, 2009 12:31 pm
by michael
http://doc.trolltech.com/4.3/porting-qsa.html

String.argDec() This function is not available in Qt Script. Use replace() or concat() instead.