BBS: Inland Empire Archive Date: 02-24-93 (16:26) Number: 296 From: CHRIS TRACY Refer#: NONE To: ALL Recvd: NO Subj: Scroll v1.0 - 1/1 Conf: (2) Quik_Bas
Well... This is a little routine i wrote to scroll an array on the screen... It's quite fast, even though it uses PRINT and locate and all that fun stuff... The original version used PrtScrn, an ASM routine from the Q4T library, but i adapted it to use PRINT... Basically, you set the screen location (you just define a box) and colors and the array and the ending key, and it will scroll very nicely for just about any number of elements (up to 32766, which is BASIC's limitations anywaz, well... depening on a few things...)... It is very handy for scrolling like an ASCII chart for instance... Note, I wrote this TO scroll an ascii chart, and of course, print messed up the control characters... So, if you use an optional PRINT statement, it will print the REAL ASCII code (like PDQPrint, PrintQ, or PrtScrn)... Oh well, here it is! Enjoy! Part one of SCROLL.BAS... ________O_/________________________| SNIP |______________________\_O_______ O \ | HERE | / O DECLARE SUB Scroll (Arry$(), Elements%, UpR%, Brw%, LfC%, Rgc%, Fore%,_ Back%, EndCode$) SUB Scroll (Arry$(), Elements%, UpR%, Brw%, LfC%, Rgc%, Fore%, Back%, EndCode$) DEFINT A-Z ' ' Scroll v1.0 - By Chris Tracy ' QBS Publishing - SURE!!! Yes!!! ' ' Arry$() - This is the array (of type STRING) to be scrolled. ' NOTE: The first element MUST be 0. ' Elements% - The number of elements to use. ' Upr% - The upper row (1-25) to scroll on. ' Brw% - The bottom row (1-25) to scroll on. ' Lfc% - The left column (1-80) to scroll on. ' Rgc% - The right column (1-80) to scroll on. ' Fore% - The foreground color of the text to be scrolled. ' Back% - The background color of the text to be scrolled. ' EndCode$ - This is the ending code's code to use. Use it like this: ' Scroll Arry$(), 130, 1,25,1,79,7,0,CHR$(27) ' The CHR$(27) would make ESCape the ending code. To use ' another character, for instance, the F1 key is ' CHR$(0) + ";" so just use that instead of CHR$(27). ' ' This source code is released into the public domain. You can use it in ' any of your programs for free, I don't care... ' LOCATE , , 0 ' Turn the cursor OFF! GOSUB Update: ' This updates the list... DO WHILE LEN(I$) = 0: I$ = INKEY$: WEND ' Wait for a key SELECT CASE I$ ' What was it? CASE CHR$(0) + "G" ' Must be HOME ... ElementToStart% = 0 ' Reset starting Num = 0 ' points and update GOSUB Update: ' the scroll CASE CHR$(0) + "O" ' Or maybe END ... ElementToStart% = Elements% - (Brw% - UpR%) ' set the start Num = Elements% ' point to the GOSUB Update: ' last ones & update CASE CHR$(0) + "Q" ' PGDN ... ElementToStart% = ElementToStart% + (Brw% - UpR%) IF ElementToStart% + (Brw% - UpR%) > Elements% THEN Num = Elements% - (Brw% - UpR%) ElementToStart% = Elements% - (Brw% - UpR%) END IF GOSUB Update: IF ElementToStart% <> 0 THEN Num = Num + (Brw% - UpR%) END IF CASE CHR$(0) + "I" ' PGUP ... ElementToStart% = ElementToStart% - (Brw% - UpR%) IF ElementToStart% < 0 THEN Num = 0 ElementToStart% = 0 END IF GOSUB Update: IF ElementToStart% <> 0 THEN Num = Num - (Brw% - UpR%) END IF CASE CHR$(0) + "P" ' Down arrow key ElementToStart% = ElementToStart% + 1 IF ElementToStart% + (Brw% - UpR%) > Elements% THEN ElementToStart% = ElementToStart% - 1 GOTO Repeat: END IF GOSUB Update: Continued on next message... --- T.A.G. 2.6d Standard * Origin: DangerBase ][ Programming Staff 412-438-4101 (1:2615/4@FIDONET.ORG)
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