Scor­pio News

  

January–March 1987, Volume 1, Issue 1











Page 13 of 63











EQUIVALENCE (X1),(X2) .. (Xn)

= where X1 4m are sequences of two or more variables or array elenents, Separaced by commas. Thus,

EQUIVALENCE (GROT(6),THTSGROT(3,2)) = allows the two arrays to share epace happily. Variables can also be EQUIVALENCED – EQUIVALENCE (4,0) = te allowed. Lf EQUIVALENCE Ls used to save program space, then make sure that you do not fall into the trap of letting one of the equivalenced variables or array overweite the other(s) The EQUIVALENCE statement is very useful if « program

Contains intermediate varaables or arrays which are not fequired in later’ stages of & program

‘The final method of space saving is to use che COMMON block statement in which arrays and variables which appese in more than one of the program subroutine fare declared as COMMON at the beginning of each:

(COMMON X17 A(20,40),NASTY(100,29 = are put in each subroutine to eave # modicum of space

In a Large program this As very handy! In the above example, arrays A and NASTY are stored ‘ins COMMON aren called 41 This area is shared by aii subroutines dn ‘which this COMMON statement appears

EXTERKAL statement

Many functions ace provided in the system Library and can he called up (as in BASIC) ‘by Lneluding their name – fof example, SIN, ADS or PEEK (in POO and Profortren) Bat othert are not available and have to be provided from another Subroutine or external function “The ETERNAL statement docs this by allowing the programmer to specify the name of the external subroutine that does the Fequired job – thus if you wanted to calculate the volume of a cylinder, Subroutine which provided the area of the top could be called in the EXTERNAL Statenene as follows:

e porry PRooRAM EXTERNAL CIRCAR

© TuIS’TS-AN EXTERNALLY SUPPLIED FUNCTION WHICH GIVES THE 4REX

© OF A cracLe. READ( 5, 10) HEIGHT

ao FORMAT’ (F803), VoL*HETOHTSCIRCAR WRETE(5,190) VOL.

100 FORMAT( CYL’ VOL 1S *,F6.3, CUBIC METRES")

Goo rurs\Ts FINE AS LONG AS ALL CYLINDERS HAVE THE SAME SIZE TOPtI1 ‘END

Wote thae if the EXTERNAL statement had been omitted, CERCAR would have been incorrectly treated as an ordinary REAL variable by the computer


This is an OCR’d version of the scanned page and likely contains recognition errors.











Page 13 of 63