28.06.2013 Views

ISO Pascal reference manual

ISO Pascal reference manual

ISO Pascal reference manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6<br />

5. For all results other than the first (left-most), move their specifications to<br />

inside the parameter brackets, at the left-hand end of the list, preserving<br />

their left-to-right order, and apply the following transformation to each,<br />

according to its type:<br />

(a) for scalar (Integer, Real(64-bit), Boolean etc) and record-type results,<br />

prefix the specification by 'VAR%<br />

(b) for results of type STRING:<br />

(1) decide on the maximum length of this string result which the<br />

procedure is expected to return for calls made from this module;<br />

(2) if this has not already been done, define a type String < M > , where<br />

< M > is the maximum result length and the type is specified as<br />

PACKED ARRAY [1.. < M > ] OF Char (as at step 3(b))<br />

(3) rewrite the specification (which should still be in the form<br />

`STRING: < res_name >'<br />

as three items in the form<br />

`VAR < res_name > : String < M >; < res_name >_max: Integer; VAR<br />

< res_name > _len: Integer'<br />

6. (a) If the remaining result is of scalar type (Integer, Real, Boolean etc)<br />

remove the result name, to leave < result_type > outside the parameter<br />

list brackets. Prefix the procedure name with the keywords IMPORT<br />

FUNCTION.<br />

(b) If the remaining result is of type RECORD, move this result<br />

specification also inside the brackets and prefix it by the keyword VAR, as<br />

in step 5(a). Prefix the procedure name with the keywords IMPORT<br />

PROCEDURE.<br />

(c) If the remaining result is of type STRING, move it inside the brackets<br />

(at the left-hand end), and rewrite it as two items: the first (left-most) a<br />

VAR parameter of type String < M > , where < M > is the maximum length<br />

of string result expected (as for step 5 (b)(1,2)); the second an Integer whose<br />

name is formed from the result name with '_len' appended. Then add<br />

Integer' after the right-hand parameter list parenthesis and prefix the<br />

procedure name with the keywords IMPORT FUNCTION.<br />

40 <strong>Pascal</strong> Issue 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!