BBS: Inland Empire Archive Date: 03-01-93 (22:19) Number: 351 From: VICTOR YIU Refer#: NONE To: CALVIN FRENCH Recvd: NO Subj: Re: Speed when counting c Conf: (2) Quik_Bas
>>> Regurgitating Calvin French to All <<< CF> IF n MOD (LOF(1) / 80) = 3 THEN 'This is what does the little CF> PRINT CHR$(177); 'bar graph at the top of the CF> END IF 'screen... original, eh? Yeah, original, but eating up 75% of your time. You should really be using an input buffer of >2K, and using direct string manipulation (PEEK/POKE). I completely rewrote your program: -----------SNIP! ' ULTRA-FAST Rewrite for Calvin French's counting program... ' by Victor Yiu, March 2, 1993. DEFINT A-Z CONST BlockSize = 1024 DIM Chars(255) CLS INPUT "Filename"; F$ OPEN F$ FOR BINARY AS #1 IF LOF(1) = 0 THEN CLOSE BEEP PRINT "Does not exist." END END IF InL& = LOF(1) DO CharsLeft& = InL& - SEEK(1) + 1 SELECT CASE CharsLeft& CASE IS > BlockSize Block$ = SPACE$(BlockSize) Chars = BlockSize CASE IS = 0 EXIT DO CASE ELSE Block$ = SPACE$(CharsLeft&) Chars = CharsLeft& END SELECT GET #1, , Block$ A = SADD(Block$) DEF SEG = VARSEG(Block$) + A \ 16 ' change to SSEG for PDS/VBDOS A = A AND 15 FOR Posit = A TO A + Chars - 1 Char = PEEK(Posit) Chars(Char) = Chars(Char) + 1 NEXT LOOP CLOSE FOR Disp = 0 TO 255 PRINT Disp; Chars(Disp) IF (Disp MOD 22) = 21 THEN PRINT PRINT "Press any key..."; Dummy$ = INPUT$(1) CLS END IF NEXT -------SNIP! That should be 100 times faster than yours. <G> ... I've got a mind like a... a... what's that thing called? --- Blue Wave/RA v2.10 [NR] * Origin: Hard Disc Cafe / Houston Texas / (713) 589-2690 / (1:106/30.0)
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