Charm Input Library (in) 

The input library contains procedures for performing stream and file input. These procedures allow applications to read data from the keyboard or files. Return status codes for read string are defined here.

Open input stream

export dynamic proc open (ref array char name) ref Rtl.ErrMsg
  • passed name - stream name
  • returns nil if successful
  1. Error record contains error details if open fails.

Close input stream


export dynamic proc close ()

 Check valid


export proc str (ref array char name) boolean
  • passed name - stream name
  • returns true if stream name is valid (can be opened)

Read character

export dynamic proc ch () char
  • returns - character 

  1. This method is primarily intended for reading from the keyboard. While it can read from a file there is no end of file status and an attempt to read beyond the file end will raise a Charm runtime error.
Read string

export dynamic proc str (ref array char buffer, int buffer_length) int
  • passed buffer - string buffer
  •            buffer_length - buffer length
  • returns status code
  1. Expect status codes:
    1. In.STR_SUCCESS for success
    2. In.STR_TRUNCATED if the string was truncated because the supplied buffer was not large enough
    3. In.STR_EOF if the end of file is reached

Read buffer

export dynamic proc buf (int buffer, int buffer_size)
  • passed buffer - buffer
  •            buffer_size - buffer size
  1. Use this method to read binary data from files.
  2. Ensure that the supplied buffer is large enough to accept the bytes read i.e. allocate a buffer of at least  buffer_size  bytes.

Read direct

export dynamic proc direct (int buffer, int buffer_size, int buffer_offset)
  • passed buffer - buffer
  •            buffer_size - buffer size
  •            buffer_offset - buffer offset
  1. Use this method to read binary data from files from a given offset.
  2. Ensure that the supplied buffer is large enough to accept the bytes read i.e. allocate a buffer of at least  buffer_size  bytes.
  3. Only valid for random access files (e.g. cannot be used for keyboard input).

Get input filename

export dynamic proc get_input_filename () ref array char
  • returns input filename
  1. Stream must be open.

Set open path

export proc set_open path (ref array char zp)
  • passed zp - path to use for unqualified  (i.e. no path) filename open request

Make a Free Website with Yola.