b = write(message ‖ msg_numʃ, argument1, ..., argumentNʅ);
The write function writes text to a write file that can be used as a report. Each argument is sequentially inserted into the write string. Arguments can be numeric or alphanumeric expressions, but the type of the argument must match the type of the receiving field in the message text. If no write file is specified at run time, the write file lines are placed in the default data entry or batch error report.
In the string expression:
%[n]d = Insert a number and display it as an integer
%[n.d]f = Insert a number and display it as a decimal value
%[n.d]s = Insert a text string
where "
n" is the size of the field and "d
" is the number of decimal places to show for a number.
For a complete list of possible message formatters, see Message Formatting Options.
Numbers are never truncated. Text strings are truncated only if ".d" is used. If "n" is positive, the insert is right-justified in the size of the field. If "n" is negative, the insert is left-justified in the size of the field. If "n" is a positive number with a leading zero, the insert is right-justified in the size of the field and zero-filled to the left. When inserting a number, if "n" is preceded by a "+", the sign of the number is always displayed.
The function returns a logical value 1 (true) if successful and 0 (false) otherwise.
numeric integerValue = 23456;
errmsg( "%d" , integerValue); // 23456
errmsg( "%-10d" , integerValue); // 23456
errmsg( "%10d" , integerValue); // 23456
errmsg( "%+10d" , integerValue); // +23456
errmsg( "%+010d" , integerValue); // +000023456
errmsg( "%-010d" , integerValue); // 0000023456
errmsg( "%f" , integerValue); // 23456.000000 Note the usage of %f
numeric decimalValue = 12.567;
errmsg( "%f" , decimalValue); // 12.567000
errmsg( "%-10.3f" , decimalValue); // 12.567
errmsg( "%d" , decimalValue); // 12 Note the usage of %d
errmsg( "%10.2f" , decimalValue); // 12.57
errmsg( "%10.3f" , decimalValue); // 12.567
errmsg( "%+10.3f" , decimalValue); // +12.567
errmsg( "%+010.3f" , decimalValue); // +00012.567
errmsg( "%010.3f" , decimalValue); // 000012.567
errmsg( "%10.5f" , decimalValue); // 12.56700
string stringValue = "abcdef";
errmsg( "%s" , stringValue); // abcdef
errmsg( "%-10s" , stringValue); // abcdef
errmsg( "%-10.3s" , stringValue); // abc
errmsg( "%10s" , stringValue); // abcdef
errmsg( "%10.3s" , stringValue); // abc