BBS: Inland Empire Archive Date: 04-11-92 (13:54) Number: 153 From: JEAN CREPEAU Refer#: NONE To: MARK SWEENEY Recvd: NO Subj: Scroll Back Screen Conf: (2) Quik_Bas
In a message to ALL, MARK SWEENEY wrote: MS=> I'm trying to write a frontend for an online game on delphi. I need a scroll back screen like the one in telix but am not sure how to go about writeing it any help would be welcome. You could try to store each line in a different string variable. You just have to use a string array as a queue. For example, if you want to remember 1000 lines, use the following routines: '**************************************************************** '* Initial Scroll Back buffer * '**************************************************************** DIM SHARED ScrlBack$(999) ' To remeber 1000 lines '**************************************************************** '* This subroutine clears the Scroll Back buffer * '**************************************************************** SUB ClearQueue SHARED QSize,QCur QSize=0 QCur=0 ERASE ScrlBack$ END SUB '**************************************************************** '* This subroutine adds a line in the Scroll Back buffer * '* If the Buffer is full, the oldest line is removed * '* Entry: X$ contains the line to add to the queue * '**************************************************************** SUB WriteQueue(x$) SHARED QSize,QCur ScrlBack$(QCur)=x$ QCur=QCur+1 IF QCur>UBOUND(ScrlBack$,1) THEN QCur=0 IF QSize<UBOUND(ScrlBack$,1)+1 THEN QSize=QSize+1 END SUB '**************************************************************** '* This subroutine reads a line from the scroll back buffer * '* Entry: N is the line number * '* if N=>0, N represents the Nth line in the buffer * '* if N<0, N represents the -Nth last line in the buffer * '* (N=0 returns the first line, N=1 the second * '* one, while N=-1 returns the last one) * '* Exit: ReadQueue$ is the line in the buffer if it exists * '* Blank lines are added a space (ASCII 20h). * '* If the line number is out-of-range, ReadQueue$ = "" * '**************************************************************** FUNCTION ReadQueue$(n) SHARED QSize,QCur ARS=UBOUND(ScrlBack$,1)+1 IF N<0 AND QSize+N=>0 THEN Q=QCur-N IF Q=>ARS THEN Q=Q-ARS ELSEIF N=>0 AND QSize>N THEN Q=QCur-QSize+N IF Q<0 THEN Q=Q+ARS ELSE Q=-1 ENDIF IF Q<0 THEN Z$="" ELSE Z$=ScrlBack$(Q):IF Z$="" THEN Z$=" " ENDIF ScrlBack$=Z$ END FUNCTION --- * Origin: INTERACESS Montreal (QC) Canada (514) 528-1415 (1:167/280)
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