- The standard Format option is used in the READ and WRITE functions.
- ⇒how to define formats for (file-) MatrixExplorer and SORT
- To display and edit a file or an array the DLG function also uses the Format option.
- Not all Format variations make sense in these 4 functions, e.g. there cannot be a display with binary format in DLG.
- Numerics and strings can be freely mixed in one statement
- integer and real formats can be used for all numeric data (numeric values are internally stored as 64 bit floating point
- for interactive examples see Tutorial.hic(Format) and Tutorial.hic(PictureFormat)
- (Fortran standard)
- WRITE(Format=fmt) 1, 21.9, 314.15, -4.51, 123456789 ! sample output real numbers
| | Syntax (*) | fmt sample | 1 | 21.9 | 314.15 | -4.51 | 123456789 |
| I integer | [r]Iw[.m] | 5i10 | 1 | 21 | 314 | -4 | 123456789 |
| F real | [r]Fw.d | 5F10.2 | 1.00 | 21.90 | 314.15 | -4.51 | 123456789 |
| E exponent | [r]Ew.d[Ee] | 5E10.2 | 0.10E+01 | 0.22E+02 | 0.31E+03 | -0.45E+01 | 0.12E+09 |
| ES scientific | [r]ESw.d[Ee] | 5ES10.2 | 1.00E+00 | 2.19E+01 | 3.14E+02 | -4.51E+00 | 1.23E+08 |
| EN engineering | [r]ENw.d | 5EN10.2 | 1.00E+00 | 21.90E+00 | 314.15E+00 | -4.51E+00 | 123.46E+06 |
| EN exp ctrl | [r]ENw.d[Ee] | 5EN10.2e1 | 1.00E+0 | 21.90E+0 | 314.15E+0 | -4.51E+0 | 123.46E+6 |
| G all | [r]Gw.d[Ee] | 5G10.2 | 1.0 | 22. | 0.31E+03 | -4.5 | 0.12E+09 |
(*) w=width, d=digits, r=repeat count, m=minimum places, Ee=exponential places, [optional] - (Fortran standard)
- WRITE(Format=fmt) 0, 1, 16, 65, 255 ! sample output integer numbers
| type | Syntax | fmt sample | 0 | 1 | 16 | 65 | 255 |
| I integer | [r]Iw[.m] | 5I10 | 0 | 1 | 16 | 65 | 255 |
| L logical | [r]Lw | 5L10 | F | T | T | T | T |
| Z hexadecimal | [r]Zw[.m] | 5Z10 | 0 | 1 | 10 | 41 | FF |
| O octal | [r]Ow[.m] | 5O10 | 0 | 1 | 20 | 101 | 377 |
| B binary | [r]Bw.m | 5B10.1 | 0 | 1 | 10000 | 1000001 | 11111111 |
- (Fortran standard)
- WRITE(fmt="a, "(format embedded string)", 3x, a12") "automatic length", "(length limited)"
automatic length (format embedded string) (length limi
- To facilitate the etc., HicEst allows to by the use of numeric formats. Only the width is used then, e.g.
WRITE(fmt="(I5, F8.2/)") "int", "value", 1, 2, 3, 4 ! this will output:
int value
1 2.00
3 4.00
- :
- "," commas separate the list items as in the above examples
- "/" slash instead comma starts next record
- "nX" skips n positions
- "[n](...)" to repeat the enclosed formats [n times]
- :
Format="Fw"
(Fortran standard requires Fw.d) for output with : WRITE(Format="(F4)") 1, "abc", 1/2, "defg", 1/3, "hijklmn", 1/4
1 abc0.5 defg0.33hijk0.25
- :
Format="F"
, read the next available numeric values
to scalar or arrays: - READ(Text="ABC=-1.23, Value2 is 4E3", Format="3F") a, b, c ! assigns a = -1.23, b=2, c=4000
- READ(Text=string(1:30), items=n) vec ! n = elements found, the array vec is filled from left to right
- :
Format="F"
writes numeric values, maximum is 10 digits: - WRITE(Format="(F)") 1, 1/2, 1/3, 1/4
- 1 0.5 0.3333333333 0.25
or for a vector of dimension 12: - REAL :: vec(12)
- vec = $^3 ! fills vec with the index cubes
- WRITE(Fmt="(F)") vec ! will result in "1 8 27 64 125 216 343 512 729 1E3 1331 1728"
- : these internal formats work with character strings as well as with disk files. Binary formats can be mixed with all other formats.
| type | Format | range | decimal places |
| unsigned binary 1-Byte integer | [r]ib1 | 0 .. 255 | 2....3 |
| signed binary 2-Byte integer | [r]ib2 | -32768 .. 32767 | 4....5 |
| signed binary 4-Byte integer | [r]ib4 | -2147483648.. 2147483647 | 9...10 |
| signed binary 8-Byte integer | [r]ib8 | -9.22337E18.. 9.22337E18 | 18...19 |
| signed binary 4-Byte real | [r]fb4 | ±1.18E-38 .. ±3.40E38 | 6....7 |
| signed binary 8-Byte real | [r]fb8 | ±1.00E-300 .. ±1.00E300 | 15..16 |
- WRITE(Text=tx, fmt="IB1,IB2") 65, 66+256*67 ! writes "ABC"
- (CHAR(65)=="A", CHAR(66)=="B", CHAR(67)=="C")
- READ(Text=tx, fmt="IB1,IB2") x, y ! makes x=65, y=17218 if tx was written with above statement
- : Format="U...":
- read or write days in Microsoft (Excel) compatible days. Day 1 is Dec. 31, 1899
- fractional days are transferred to hours, minutes, seconds, milliseconds
- the strings following the "U" are case sensitive:
-
| CC | YY | MM | DD | HH | mm | SS | sss | W or WW or WWW |
| Century | Year | Month | Day | Hour | minute | Second | msec | day of the week |
- WRITE(Format="UDD.MM.CCYY" ) 1 ! days > 0: writes "31.12.1899"
- WRITE(Format="UYY/MM/DD HH:mm" ) 0 ! days <=0: current day+time "07/09/22 19:06"
- WRITE(Format="UHH:mm:SS sss msec") 0 ! writes "19:06:59 249msec"
- WRITE(Format="UWWW MM-DD HH.mm") 0 ! writes: "Sun 12-22 19.06"
- READ(text="03:00 1899/12/30", fmt="UHH:mm CCYY MM DD") day ! day --> 0.125
- READ(text="03:00", fmt="UHH:mm") day ! default = 1899/12/30, day --> 0.125
- READ(text="22.09.07 06:00", fmt="UDD.MM.YY HH:mm") day ! default century CC is 20, day --> 39347.25
- READ(text="1899/12/29", f="UCCYY MM DD") day ! day --> -1
- any other text can be freely interspersed.
- matches the output list to the given format string, like in:
- WRITE(R=1, fmt=template) 79, "hello", pi, -678, "RESULT"
123 Rightalign 1.2345 keep this 1.2E+01 C_this_is_the_template
79 hello 3.1416 keep this -6.8E+02 RESULT
- template text tokens starting with L, C, or R is Left or Center or Right aligned
- for an interactive demo see Tutorial.hic(PictureFormat)