BBS: Inland Empire Archive Date: 02-10-93 (22:04) Number: 346 From: DONN BLY Refer#: NONE To: DAVID DUREL Recvd: NO Subj: Re: BACKWARDS FILE READIN Conf: (2) Quik_Bas
> Does anyone out there have a simple routine to read an ASCII file > backwards? > In other words, start from the end of the file and read to the > beginning, instead of the other way around. You mean like this: SUB DispBackward1 (FileName$) FileNum% = FREEFILE Buff$ = " " OPEN FileName$ FOR BINARY AS #FileNum% FOR I& = LOF(FileNum%) TO 1 STEP -1 GET #FileNum%, I&, Buff$ PRINT Buff$; NEXT CLOSE #FileNum% END SUB or this: SUB DispBackward2 (FileName$) FileNum% = FREEFILE Buff$ = " " OutLine$ = "" OPEN FileName$ FOR BINARY AS #FileNum% I& = LOF(FileNum%) DO WHILE I& GET #FileNum%, I&, Buff$ OutLine$ = Buff$ + OutLine$ IF ASC(Buff$) = 13 THEN PRINT OutLine$; OutLine$ = "" END IF I& = I& - 1 LOOP IF LEN(OutLine$) THEN PRINT OutLine$ CLOSE #FileNum% END SUB --- OPMED 3.00 * Origin: The Loft *HST/V32b/V42b* [NC, SDS] (1:236/7)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET