Download AmberTools Users` Manual

Transcript
7.4 Statements
part of the float. The use of the star (*) as an output width or precision indicates that the width
or precision is specified as the next argument in the conversion list which allows for runtime
widths and precisions.
Ouput format options
Alignment
left justified
default right justified
Padding
0
%d, %f, %s only, left fill with zeros, right fill with spaces.
+
%d, %f only, precede non-negative numbers with a +.
default left and right fill with spaces.
Width & precision
W
minimum field width of W . W is either an integer or a * where the star
indicates that the width is the next argument in the parameter list.
W.P
minimum field width of W , with a precision of P. W,P are integers or
stars, where stars indicate that they are to be set from the appropriate
arguments in the parameter list. Precision is ignored for %c and %d.
.P
%s, print the first P characters of the string or the entire string
whichever is shorter. %f, print P decimal places in a field wide enough
to hold the integer and fractional parts of the number. %c and %d, use
whatever width is required. Again P is either an integer or a star where
the star indicates that it is to be taken from the next expression in the
parameter list.
default %c, %d, %s, use whatever width is required to exactly hold the data. %f,
use a precision of 6 and whatever width is required to hold the data.
7.4 Statements
nab statements describe the action the nab program is to perform. The expression statement
evaluates expressions. The if statement provides a two way branch. The while and for statements
provide loops. The break statement is used to “short circuit” or exit these loops. The continue
statement advances a for loop to its next iteration. The return statement assigns a function’s
value and returns control to the caller. Finally a list of statements can be enclosed in braces ({})
to create a compound statement.
7.4.1 Expression Statement
An expression statement is an expression followed by a semicolon. It evaluates the expression. Many expression statements include an assignment operator and its evaluation will update
the values of those variables on the left hand side of the assignment operator. These kinds of
expression statements are usually called “assignment statements” in other languages. Other expression statements consist of a single function call with its result ignored. These statements
take the place of “call statements” in other languages. Note that an expression statement can
contain any expression, even ones that have no lasting effect.
157