CoCoA:Get

From ApCoCoAWiki

Get

read characters from a device

Description

This function reads N characters from D and returns the list of

their ascii codes.

Example

  D := OpenIFile(<quotes>io.cpkg</quotes>);  -- open the file <quotes>io.cpkg</quotes>
  Get(D,10);  -- get the first 10 characters
[45, 45, 32, 105, 111, 100, 101, 118, 46, 112]
-------------------------------
  Ascii(It); convert the ascii code to characters
-- iodev.p
-------------------------------
  Ascii(Get(D,10));  -- get the next 10 characters and convert
kg : 0.1 :
-------------------------------
  Close(D);

The instruction Get(DEV.STDIN,3), for instance, will read 3 characters typed in by the user. Clever use of this function can be used to prompt a user for input to a function, although it is usually easier for functions to take input directly as arguments. NOTE: this function does not work properly under the GUI Interface.

Syntax

Get(D:DEVICE,N:INT):LIST of INT

Introduction to IO

OpenIFile

OpenOFile

OpenIString

OpenOString

   <type>io</type>
   <type>printing</type>