BBS: Inland Empire Archive Date: 04-15-92 (13:37) Number: 63 From: DON KROUSE Refer#: NONE To: BILL BEELER Recvd: NO Subj: Qprint Conf: (2) Quik_Bas
BB>In a message to John Gallas <07 Apr 92 17:51> Don Krouse wrote: BB> DK> DEFINT A-Z BB> DK> DECLARE SUB PrintFast (Rows%, Col%, Msg$, atrib%) BB> DK> PrintFast 5, 25, "This is Pretty Fast", 31 BB> DK> SUB PrintFast (Rows%, Col%, Msg$, atrib%) BB> DK> place% = ((((Rows - 1) * 80) + Col) - 1) * 2 BB> DK> DEF SEG = &HB800 ' Use &HB000 for mono systems BB> DK> FOR i = 1 TO LEN(Msg$) BB> DK> POKE place%, ASC(MID$(Msg$, i, 1)) BB> DK> POKE place% + 1, atrib BB> DK> place% = place% + 2 BB> DK> NEXT i BB> DK> DEF SEG BB> DK> END SUB BB>Don, BB>You might try putting a STEP 2 at the top of the FOR loop and discard the BB>incrimentation of place...it *might* speed it up even more. Hi Bill, It DEFINITLY does speed it up. After reading your message I fired up QB, inserted the STEP 2 and remmed out 'place% = place% + 2. I then quickly compiled and ran the test. When I read the output file I almost dropped my coffee cup in my lap, the times were twice as fast with the modification. Then I realized that the reason that the times were twice as fast was because the string was half as long. The FOR/NEXT counter is the length of the string being printed therefore using STEP 2 prints every other character. I did try using STEP 2 with the memory address as the counter but the additional math required to determine what character to print slows it down about 3% to 5% depending on the string length. (see below) I do appreciate the thought, if you have any more I'd like to here them. Don Modified (slower) version - note (\) integer division SUB PrnFast (Rows%, Col%, Msg$, atrib%) start% = ((((Rows - 1) * 80) + Col) - 1) * 2 ending% = (place% + LEN(Msg$) * 2) - 1 DEF SEG = &HB800 FOR i = start% TO ending% STEP 2 POKE i, ASC(MID$(Msg$, ((i - start%) \ 2) + 1, 1)) POKE i + 1, atrib NEXT i DEF SEG END SUB --- * Origin: Silver Lake Systems * Bothell,WA (1:343/58)
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