Jump to content

2048: Difference between revisions

m
→‎Source: FORMAT statements can be various.
m (→‎{{header|REXX}}: added wording to the REXX section header.)
m (→‎Source: FORMAT statements can be various.)
Line 2,179:
22 FORMAT ("|",666A1) !A constant FORMAT, a tricky WRITE.
4 FORMAT ("|",<NC - 1>(<W>("-"),"+"),<W>("-"),"|") !With internal + rather than |.</lang>
This sort of thing is not necessarily accepted by all compilers, so instead the next stage was to convert to using complicated WRITE statements. If one regarded the various sizes (the values of NR, NC, W in the source) as truly fixed, literal constants could be used throughout. This would however mean that they would appear without explanation, and if one eventually attempted to recode with different values, mistakes would be likely. Thus below, FORMAT 3 has <code> (<NC>(A1,I<W>),A1)</code> and if the <> scheme were unavailable, you'd have to use <code>(4(A1,I6),A1)</code> instead, not too troublesome a change. Or, the text of the format sequence could be written to a CHARACTER variable, as demonstrated in [[Multiplication_tables#Traditional_approach]]. Yet another approach might be <code>(666(A1,I6))</code> which relies on the addendum <code>A1</code> happening to be the same as the start of the <code>(A1,I6)</code> pair, but there is still the appearance of the literal constant, six, and if there were to be any change to be made, it would have to be remembered...
<lang Fortran> SUBROUTINE SHOW(NR,NC,BOARD) !Mess about.
INTEGER NR,NC !Number of rows and columns.
1,220

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.