Number: 1274

Date: 30-May-84 16':58':16

Submitter: Sannella.PA

Source: JonL.pa

Subject: Document AIN and AOUT functions

Lisp Version: 

Description: '
Date': 30 MAY 84 15':42 PDT'
From': DEUTSCH.PA'
Subject': Fixed-length strings'
To':   LispSupport'
'
After looking through the Interlisp-D manual and thinking back through'
the 20-odd years I''ve been programming in Interlisp, I find I don''t see'
how to do the following two simple things':'
	- Create a string N characters long (contents ad lib)'
	- Read the next N characters from a file'
Are there functions buried somewhere in there that do this things already?'
'
-----'
'
Date': 30 MAY 84 15':49 PDT'
From': DEUTSCH.PA'
Subject': Ignore 1/2 of previous message'
To':   LispSupport'
'
I looked through a newer version of the manual and found ALLOCSTRING.'
I still don''t see how to read N characters from a file.'
'
-----'
'
Date': 30 May 84 16':45 PDT'
From': JonL.pa'
Subject': Re': Fixed-length strings'
In-reply-to': DEUTSCH.PA''s message of 30 MAY 84 15':42 PDT'
To': DEUTSCH.PA'
cc': LispSupport.PA'
'
I see you already found ALLOCSTRING.'
'
As for reading the next n bytes from a file, I suppose you mean "reading them destructively into a  ''buffer'' of some sort, such as a string";  if you don''t mean this, then'
    (FRPTQ n (READC file))'
is about as good as any, right?'
'
Otherwise, the unfortunately-still-undocumented function AIN would suffice; it will gobble up n bytes from a file and stuff them into a string (or an array of appropriate type -- appropriate types are BYTE, and in general FIXP type arrays, whereby the bytes are dribled directly into the words of the array).  For example,'
   (SETQ BUF (ALLOCSTRING 10))'
   (AIN BUF 1 10 file)'
where the "1" is there because its meaning is interpreted in the origin-index of the array/string (strings are considered 1-origin), and where "10" is the total number of bytes to move in.'
'
AIN uses an undocumented, system-implementor level, function named \BINS for "Byte INput to Storage".  I don''t think it does coercion on its arguments, so you have to have a STREAM for the "file"; furthermore, it is not "memory-system safe" since its 2nd through 4th arguments are just a random memory address, offset, and length count.  Its certainly possible, at this undocumented-subject-to-change level, to do'
   (\BINS INPUTSTREAM '
          (fetch (STRINGP BASE) of BUF) '
          (fetch (STRINGP OFFST) of BUF)'
          (fetch (STRINGP LENGTH) of BUF))'
and, modulo EOF conditions, this would fill up the string'
'
-- JonL --'
'
P.S.  Mike': if there isn''t an AR about lack of documentation in the IRM abourt AIN and AOUT, maybe you could submit one?'
'
'


Workaround: 

Test Case: 

Edit-By: 

Edit-Date: 30-May-84 16':57':04

Attn: Kaplan, Jonl

Assigned To: 

In/By: 

Disposition: 

System: Operating System

Subsystem: Generic File Operations

Machine: 

Disk: 

Microcode Version: 

Memory Size: 

File Server: 

Server Software Version: 

Difficulty: Easy

Frequency: Everytime

Impact: Moderate

Priority: Perhaps

Status: Open

Problem Type: Documentation

Source Files: