This section applies if—
the court proceeds under section 6 in pursuance of section 19 or 20, or
the prosecutor ... applies under section 21.
In such a case—
the prosecutor ... must give the court a statement of information within the period the court orders;
section 16 applies accordingly (with appropriate modifications where the prosecutor ... applies under section 21);
section 17 applies accordingly;
section 18 applies as it applies in the circumstances mentioned in section 18(1).