eggestad%vax.runit.unit.uninett@TOR.NTA.NO (Kalle) (09/11/87)
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 indi- cates 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... Any kind of help will be deeply appreciated ! With regards, Karl Henrik Eggestad, Research Scientist - Computing Centre at the University of Trondheim, Norway Please reply to: eggestad@vax.runit.unit.uninett (EAN / Arpa) kalle@norunit (EARN / Bitnet) =============================== disclaimer ================================== The problems indicated above does not necessarily need to be the problems of my employer - though - anyway - they will soon be, if i cannot get them solved in due time. ============================= EndOfDisclaimer ===============================
THURY%MCOPN1@eg.ti.COM (Denny Thury -- VAX System Sup -- 952-2066) (09/12/87)
> 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