This is part of the HicEst documentation

READ: Input from Text Strings, Files, Clipboard, and Window

READ is the companion function to WRITE. Often the FOrmat keyword is needed to interpret the data correctly. Files require a preceding OPEN.

⇾Home ⇾Contents ⇾more Input_Output ⇾ Examples

⇾direct_read ⇾formatted_sequential_read ⇾get_file_length ⇾inquire_operations ⇾matrix_file_read ⇾medium_to_read_from ⇾next_occurence ⇾numeric_search_matrix_file ⇾paste_from_clipboard_to_string ⇾read_n-th_file_line ⇾record_n_of_direct_file ⇾search_files_for_string ⇾start_position_file_search ⇾stream-io_read ⇾string_search_matrix_file ⇾unformatted_sequential_read

Optional keywords:
(Syntax of optional keywords)
CLoSe ClipBoard Column DecimalPoint ERror FIle Format IOStat ItemS LENgth Messagebox Rec Row SEArch Text WINdowhandle
keyword type mini sample (keyword order is irrelevant)
Text txt t=txt
  • txt can be a character constant, or a variable defined by any of the CHARACTER, CHAR, ALIAS, EDIT-Parse commands
  • READ(Text="pi=3.14, i = -123, catch22") a, b, c ! a,b,c numeric. Assigns a=3.14 b=-123 c=22
  • READ(Text="pi=3.14, i = -123, catch22") str1, str2 ! both CHARACTER*10: str1="pi=3.14, i" str2=" = -123, c"
  • READ(Text="pi=3.14, i = -123, catch22", fmt="F,5X,I5,A") a, b, str1 ! assigns: a=3.14 b=-123 str1=", catch22 "
FIle txt fi=name
  • to read a file, the file must be OPENed first. This defines whether the file is:
    (the default). Records are separated by $CRLF or $LF:
    • OPEN(FIle=name)
    • READ(FIle=name) A ! read next line A in free format: For A numeric the 1st numeric value is assigned, for A character the full line is assigned
    • READ(FIle=name) A, B ! read next line A and B: For A numeric the 1st numeric value is assigned, and B is assigned the rest of the line. For A character nothing is left for B: It is assigned either 0 or blank.
    • READ(FIle=name, Row=n) text ! to text

    _==_: The number of input bytes (RecL) will match the input list
    • OPEN(FIle=nam, UNFormatted, SEQuential)
    • READ(FIle=nam, Rec=n) string ! reads LEN(string) bytes starting at byte n
  • :
    • OPEN(FIle=nam, RecL=10) ! implies DIRect, address the file in 10-byte fractions:
    • READ(FIle=nam, rec= n) str1 ! read n-th 10-byte fraction
  • : A file that is not suited for direct read because the records have variable lengths, can be read the following way (for more see OPEN and MatrixExplorer).
    • OPEN(FIle=nam, fmt='6 ,') ! sequential, 6 records per row, separated by blanks
    • DLG(Edit=nam, fmt='6A20') ! opens spreadsheet for edit, column width 20
    • str = nam(123, 4) ! assigns element 4 of row 123 of file "nam" to str. A dialog opens on error
    • str = nam(123, 0) ! assigns the full row 123 of file "nam" to str. A dialog opens on error
    • str = nam(123, 4, *999) ! on error control is transferred to label 999, ⇾ more
    • READ(FIle=nam, Row=123, Column=4) str123_4, str123_5 ! sequentially read multiple column elements in a row
    • READ(FIle=nam, Row=123, Column=0) full_line ! column=0: read full line 123
  • to just search a file: see also SEArch
(with FIle )
num r=789 record number of a file OPENed for UNFormatted SEQuential or DIRect i/o
  • OPEN(FIle=name, DIRect, RecL=40) ! open name for direct input/output, needs the record length RecL
  • READ(FIle=name, Rec=n) text ! to text
ClipBoard --- cb
Messagebox [O] m="?a"
  • WRITE(Messagebox=options, IOStat=selected_button) io_list
( ⇾ see details). Program input is by the IOstat option.
WINdowhandle NUM win=wh Obsolete, use the DLG function instead. If WIN is missing, input is prompted from the script window.
  • READ(Row=2, Column=40, fmt='A40') sample ! this will prompt and read from the HicEst main window
CLoSe log cls=1 closes, cls=-1 truncates file after current position
SEArch txt sea="??"
  • OPEN(file=nam)
  • READ(FIle=nam, search="xyz") string ! search of "xyz" in nam and read containing line into string
  • READ(FIle=nam, sea="xyz", Rec=byteNr) string ! byteNr is the
  • on input: byteNr is the start byte, on output byteNr>0 is the start position of the search string
  • optional: if the search string is prefixed by "C" and ":" : search Case sensitive (e.g. search="case:xyz")
  • with a "W" and ":" prefix: search for full Words (e.g. search="Word:xyz")
  • see also matrix file read
    • OPEN(FIle=nam, fmt="6 ,") ! 6 blank separated items per row
    • row = INDEX(nam(row1,3), 'xyz') ! search column 3 for xyz starting in row1. The find is in row
    • row = INDEX(nam(1,3), 1E10', 32) ! search column 3 for 1E10, option 32 "nearest" finds the maximum (see INDEX)
Formatted READ for all input media
Format txt f='F6.2, 2a4' ⇾ see Format for details
DecimalPoint txt dp="," default is ".".
  • READ(Text="€123,45 $123.45", DecPt=",") euros, dollars, cents ! assigns euros=123.45, dollars=123, cents=45
IOStat NUM ios=stat get completion code of a READ or get return button number of a READ(Messagebox)
ItemS NUM is=count
  • READ(..., ItemS=n) input_list ! n is the number of successfully read items of the input_list
LENgth NUM L=len
ERror LBL err=999 on error jump to label

Support HicEst   ⇾ Impressum
©2000-2019 Georg Petrich, HicEst Instant Prototype Computing. All rights reserved.