up previous next

Get

Syntax

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

Summary

read characters from a device

Description

This function reads N characters from D and returns the list of their ascii codes.

example

    
D := OpenIFile("io.cpkg");  -- open the file "io.cpkg"
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);
        
    
Note: 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.

See Also