functions fprint hoc_stdio sred xred fscan printf wopen getstr ropen xopen
IO
hoc_stdout("filename")
hoc_stdout()
Only one level of swiching allowed. Switching back to original causes future output to append to the stdout. Switching to "filename" writes stdout from the beginning of the file.
proc p() { print "one" // to original standard out hoc_stdout("temp.tmp") print "two" // to temp.tmp forall psection() // to temp.tmp hoc_stdout() print "three" // to original standard out } p()
IO
printf(format, ...)
fprint(format, ...)
sprint(string, format, ...)
Printf
places output on the standard output. Fprint
places output
on the file opened with the wopen(filename)
command (standard
output if no file is opened). Sprint
places output in its string
argument. These functions are subsets of their counterparts in
the C standard library.
Each of these functions converts, formats, and prints its arguments after the format string under control of the format string.
The format string contains two types of objects: plain characters which are simply printed, and conversion specifications each of which causes conversion and printing of the next successive argument.
Each conversion specification is introduced by the character `%
'
and ends with a conversion type specifier. The type specifiers
supported are:
Between %
and the conversion type, optional flags, width, precision
and size specifiers can be placed. The most useful flag is `-' which
left justifies the result, otherwise the number is right justified in its
field. Width and precision specifiers are of the form width.precis
.
Special characters of note are:
\n
\t
\r
Printf
and Fprint
return the number of characters printed.
printf("\tpi=%-20.10g sin(pi)=%f\n", PI, sin(PI)) pi=3.141592654 sin(pi)=0.000000 42