BBS: Inland Empire Archive Date: 02-11-93 (18:41) Number: 385 From: ROB MCKEE Refer#: NONE To: DAVID DUREL Recvd: NO Subj: BACKWARDS FILE READING Conf: (2) Quik_Bas
Hello DAVID! You wrote in a message to ROB MCKEE: -> OPEN TheFile$ FOR INPUT AS 1 -> Ptr = 0 -> DO UNTIL EOF(1) ' read the file frontwards -> Ptr = Ptr + 1 -> LINE INPUT #1, a(Ptr) -> LOOP -> FOR g = Ptr TO 2 STEP -1 ' Process it backwards DD> Thanks, but this isn't what I need.... I don't want to take DD> the time to read the entire file from the beginning. Maybe DD> someone out there has a simple assembly routine that I can DD> link to my QB code to get this problem solved. Thanks for DD> the reply, anyway. Ahh... You mean Read it Line by Line Backwards... something Like this.. DEFINT A-Z Buffer = 8192 CrLf$= Chr$(13)+ chr$(10) TheHandle = FREEFILE Open TheFile$ for Binary as TheHandle If Buffer > Lof(1) then Buffer = CurPtr - 1 CurPtr& = Lof(1)-Buffer A$= Space$(Buffer) Do until CurPtr&=<0 If Buffer > CurPtr then Buffer = CurPtr - 1: a$=Space$(Buffer) Get #1,CurPtr&,a$ for t= Buffer-1 to 1 step -1 If mid$(a$,t,2) = CrLf$ then EndOfLine = t CurPtr&= CurPtr&-t+2 ' put point to be even for g= t-1 to 1 step -1 If mid$(a$,g,2) = CrLf$ then StartOfLine = g+2 TheCurLine$= mid$(a$,StarOfLine,EndOfLine-StarOfLine-1)~ ' Save It or Whatever CurPtr&=CurPtr&-(EndOfLine-StarOfLine+1) EndOfLine=0 Exit For EndIf next endif next loop The Above code is untested & very ineffiecent but it should work... I don't think you'll be running into any lines longer than 8192 chars long.. Catcha Later , I'll see you on the flip side - Rob --- timEd/B6 * Origin: Another Quik_Bas Point in Richmond, CA (1:125/411)
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