READ from TeXt, FIle, ClipBoard, WINdow (f)

⇒Help ⇒Contents ⇒Input-Output (⇒Optional Keywords Syntax)

Bookmarks:
  ⇒direct 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   ⇒sequential read   ⇒start position for file search   ⇒stream-io read   ⇒string search matrix file

Optional keywords:
ClipBoard CLoSe Column DecimalPoint ERror FIle Format IOStat ItemS LENgth Messagebox Rec Row SEArch Text WINdowhandle
keyword type mini sample

medium to read from

(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, see OPEN. This defines whether the file is:

    sequential read

    (the default):
    • OPEN(FIle=name) ! records terminated by $CRLF
    • READ(FIle=name) a, b, c ! read from

      next

      line
    • READ(FIle=name, Row=n) text !

      read n-th file line

      into text
  • direct read

    :
    • 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
  • stream-io read

    • OPEN(FIle=nam, BINary) ! implies DIRect and RecL determined by length of input list, start address in bytes:
    • READ(FIle=nam, rec=7) str ! reads LEN(str) bytes starting at byte 7
  • matrix file read

    : A file not suited for direct read because the records have variable lengths can be read this way, 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, 4, *999) ! on error control is transferred to label 999, ⇒ more
  • to just search a file: see also SEArch

Rec


(

with FIle

)
num r=789 record number of a file OPENed for

direct input

  • OPEN(FIle=name, DIRect, RecL=40) ! open name for direct input/output, needs the record length RecL
  • READ(FIle=name, Rec=n) text !

    record n of direct file

    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_files for string

SEArch

txt sea="??"
  • 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")
  • string search matrix file

    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
  • numeric search matrix file

    • 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

inquire operations

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



©2000-2008 Georg Petrich, HicEst Instant Prototype Computing. All rights reserved.
Impressum