Search                        Top                                  Index
HELP DISCIN                                   Steven Hardy, January 1978
                                      Revised by John Williams, May 1993

    discin(file_name) -> char_rep

The procedure discin takes a file name as argument, and returns a
character repeater procedure (analogous to * charin), which reads
characters one at a time from the given file.

For example:

    discin('myfile.p') -> rep;

This creates a character repeater procedure for the file 'myfile.p'
and assigns it to the variable "rep". Successive calls of "rep", i.e.

    rep() -> char;

return successive characters from the file 'myfile.p'. The special
object * termin is returned when the end of the file is reached.

If the file name given to discin is a word, the value of the variable
* pop_default_type (normally '.p') is appended to that word, so

    discin("myfile")
and
    discin('myfile.p')

are equivalent.

discin can also be given a * DEVICE record as argument, in which case a
procedure that reads successive characters from that device is created.

The underlying device record associated with a character repeater
produced by discin can be accessed with the procedure * discin_device.
This can be useful if you want to test for input on the device, or close
it, for example. See REF * CHARIO for more details.


See also:
    HELP * DISCOUT      for creating character consumer procedures
    HELP * DEVICE       introduction to Poplog "device" records
    HELP * INCHARITEM   procedure for converting character repeaters
                        to item repeaters

    REF * CHARIO        reference guide to Poplog character stream i/o


--- C.all/help/discin
--- Copyright University of Sussex 1993. All rights reserved.