$ ADA/LIST ARRAY1 1 -- SAMPLE TO DEMONSTRATE SIMPLE ARRAYS ( no use statements ) 2 3 with TEXT_IO ; 4 5 procedure ARRAY1 is 6 7 -- dimension the array BALANCES with subscripts ranging form 1 to 20 8 -- and having each element of the array be a floating point number 9 BALANCES : array ( 1..20 ) of FLOAT := ( 1 .. 20 => 0.0 ) ; 10 11 -- declare the variable OPEN_ACCOUNTS to be integer and initialized 12 -- to zero. This will be the number of entries used in the array. 13 OPEN_ACCOUNTS : INTEGER := 0 ; 14 15 package INT_IO is new TEXT_IO.INTEGER_IO ( INTEGER ) ; 16 package FLT_IO is new TEXT_IO.FLOAT_IO ( FLOAT ) ; 17 18 begin 19 20 -- zero out the array in execution 21 for I in 1 .. 20 loop -- better to use BALANCES'RANGE for 1..20 22 BALANCES ( I ) := 0.0 ; 23 end loop ; 24 25 -- increment the array pointer and put in data 26 OPEN_ACCOUNTS := OPEN_ACCOUNTS + 1 ; 27 BALANCES ( OPEN_ACCOUNTS ) := 1.5 ; 28 29 -- any integer expression can be used as a subscript 30 BALANCES ( OPEN_ACCOUNTS + 1 ) := 0.732_175E6 ; 31 -- note: floating point numbers can use scientific notation 32 -- but be sure to use at least one digit before and after the point 33 34 INT_IO.PUT ( OPEN_ACCOUNTS ) ; 35 TEXT_IO.PUT_LINE ( " open accounts " ) ; 36 FLT_IO.PUT ( BALANCES ( OPEN_ACCOUNTS ) ) ; 37 TEXT_IO.PUT_LINE ( " is balance, no formatting " ) ; 38 FLT_IO.PUT ( BALANCES ( OPEN_ACCOUNTS ), FORE=>5, AFT=>2, EXP=>0 ) ; 39 TEXT_IO.PUT_LINE ( " is balance, named parameters " ) ; 40 FLT_IO.PUT ( BALANCES ( OPEN_ACCOUNTS ) , 5 , 2 , 0 ) ; 41 TEXT_IO.PUT_LINE ( " is balance, positional parameters " ) ; 42 43 end ARRAY1 ; $ ACS LINK ARRAY1 $ RUN ARRAY1 1 open accounts 1.50000E+00 is balance, no formatting 1.50 is balance, named parameters 1.50 is balance, positional parameters