SAY /FORMAT
Keywords: sic

Next: SAY /NOADVANCE Up: SAY Previous: SAY Contents Index

###
SAY /FORMAT

            [SIC\]SAY Arg1 Arg2 [... ArgN] /FORMAT fmt1 fmt2 [...fmtn]

        where fmt1 applies to Arg1, and so on. The format used is a Fortran for-
        mat (so it may be slightly machine-dependent). Use formats like a10, i2,
        f5.2, and so on. For example:
            SIC> say '2*pi' /format F4.2
            6.28
        Be careful that each argument must be separated by blanks (see "Multiple
        arguments" vs "Concatenated arguments" in the main HELP SAY).

        Formatting a scalar variable:
            Note also that the /FORMAT context, SAY is able to format a variable
            without a pre-evaluation by Sic. For example:
                SIC> say pi
                pi
                SIC> say 'pi'
                3.1415926535898
                SIC> say pi /format F4.2
                3.14
                SIC> say 'pi' /format F4.2
                3.14
            1) In the first case, SAY considers  unquoted  arguments  as  simple
               strings to be displayed "as is".
            2) In the second case, using single-quotes, Sic translates the vari-
               able contents to a text representation which is then given to SAY
               (SAY  is  not  aware  that  a floating point variable is involved
               here).
            3) In the third case, a floating point format is requested: this  is
               an indication to SAY that the argument must be a numeric variable
               which has to be converted in a specific way. Here SAY knows it is
               dealing with a variable.
            4)  And  finally, the last form should be avoided! The single-quotes
               are a request to Sic to translate the variable to a string  using
               its best format (same as second case). Then this string is passed
               to SAY. As the /FORMAT option is present, SAY  re-interprets  the
               ASCII  string into a floating-point value, and then this value is
               finally formatted to its final representation.  In  other  words,
               the  following  sequence  occured:  read variable name -> get its
               floating-point value -> format as ASCII string -> read as  float-
               ing-point  value -> format as ASCII string. There are two useless
               steps, even if the result is correct as Sic avoids precision loss
               when representing numeric values.

        Formatting an array variable:
            If  the  argument is an array variable, the associated format is ap-
            plied repeatedly to all its individual values:
                SIC> define real a[4]
                SIC> let a 1.2 3.4 5.6 7.8
                SIC> say a /format f6.2
                  1.20  3.40  5.60  7.80
                SIC> say a /format 4(f6.2)  ! Equivalent
                  1.20  3.40  5.60  7.80
            Note however that the format can be used  to  display  array  values
            grouped per line, e.g.
                SIC> say a /format 2(f6.2)  ! Group 2 values per line
                  1.20  3.40
                  5.60  7.80

        Mixture  of  explicit  values,  evaluated expressions, scalar, and array
        variables:
                SIC> define integer n
                SIC> let n 4
                SIC> define integer id[n]
                SIC> let id[i] i
                SIC> say "My interferometer has " n " antennas numbered" -
                SIC-? id " providing " 'n*(n-1)/2' " baselines." -
                SIC-? /format a i0 a i3 a i0 a
                My interferometer has 4 antennas numbered  1  2  3  4 providing 6 ba