From: CSBVAX::MRGATE!@KL.SRI.Com,@RELAY.CS.NET:THURY%MCOPN1@eg.ti.com@SMTP 12-SEP-1987 01:09 To: EVERHART Subj: RE: Pascal, avoiding text files Received: from RELAY.CS.NET by KL.SRI.COM with TCP; Fri 11 Sep 87 19:09:17-PDT Received: from relay2.cs.net by RELAY.CS.NET id ad04900; 11 Sep 87 22:03 EDT Received: from eg.ti.com by RELAY.CS.NET id bi01727; 11 Sep 87 21:53 EDT Date: Fri, 11 Sep 87 16:55 CDT From: Denny Thury -- VAX System Sup -- 952-2066 Subject: RE: Pascal, avoiding text files To: INFO-VAX@KL.SRI.COM X-VMS-To: SKACSL::IN%"INFO-VAX@KL.SRI.COM" > I have - from time to time - the need of avoiding the use of the TEXT > type/identifier in VAX-Pascal programs (non ascii device control and so > on), and have several times run into the following problem: > > Files-11 text files are "piles" of VARYING strings, where the first byte > indicates how long the line is. When reading the file as either FILE OF > INTEGER or some sort of FILE OF "block", i try to skip over this > information (or handle it myself in some way) which _fails_. > > My _deeply_ behated error message is: > > .... bytes record is too big for the user's buffer. > > Any idea how to handle this ? I have wasted too much time fighting this > message by setting record-sizes, access-methods and reading parameters... > If I understand your question, it sounds like you want/need to read a variable file, but can't/don't want to use the TEXT file type. If not using the TEXT file type is the ONLY issue here, then consider the following code fragment: ====================================================================== TYPE STR = VARYING [nnn] OF CHAR ; VAR BUFF : STR ; F : FILE OF STR ; BEGIN RESET (F) ; WHILE NOT EOF(F) DO BEGIN READ (F,BUFF) ; (* notice no READLN !! *) . . Process the data here . END ; END. ====================================================================== IF, on the other hand, you need/want to read a variable file declared as an ARRAY [nnn] OF INTEGER, or somesuch, then the following code works, but with one caveat: I haven't found a way for PASCAL to tell me how large of a record was actually read! You'll have to find some other way to determine this. ====================================================================== PROGRAM READVAR (OUTPUT,F) ; (* This program demonstrates a mechanism to read a VARIABLE file from a non-TEXT or non-VARYING OF CHAR file type (file F in this example). This mechanism does NOT show how to determine the number of bytes actually read. PASCAL does not provide a way, however this info may be available if you're willing to examine the FAB or RAB associated with F. *) TYPE BYTE = [BYTE]0..%XFF ; (* Define a byte *) STR = ARRAY [1..80] OF BYTE ; (* Each record contains UPTO 80 bytes *) VAR I : INTEGER ; (* used for a loop counter *) REC : STR ; (* Buffer to receive a record *) F : FILE OF STR ; (* A file of bytes *) BEGIN (* First open the file, notice the RECORD_TYPE := VARIABLE *) OPEN (F,HISTORY:=READONLY,RECORD_TYPE:=VARIABLE) ; RESET (F) ; WHILE NOT EOF(F) DO BEGIN REC := ZERO ; (* clear out last record's data *) REC := F^ ; (* Get next record from file *) (* The file buffer (F^) is cleared out here, to prevent any carry-over for the last record read. The File I/O operation loads the record, however long/short it is, and leaves the remaining buffer space alone. *) F^ := ZERO ; FOR I := 1 TO 25 DO WRITE (HEX(REC[I])) ; (* Dump 1st 25 bytes *) WRITELN ; GET(F) ; (* Get next record *) END ; CLOSE (F) ; (* Just to be complete *) END. ====================================================================== I hope this provides some help!! Denny Thury CSnet : THURY%MCCORE@TI-EG VAX Systems Support ARPA : THURY%MCCORE@TI-EG.CSNET Texas Instruments Incorporated McKinney, Texas