BBS: Inland Empire Archive Date: 02-07-93 (06:37) Number: 375 From: ROB FLOR Refer#: NONE To: ROB MCKEE Recvd: NO Subj: MID$ function speed Conf: (2) Quik_Bas
RM>Hello Rob! > You wrote in a message to Peter Tepperman: RM>PT> I'm writing a program that makes extensive use of the MID$ function. RM> RF> Its a fast way to replace strings of equal size, a slow > RF> way to find the ascii value of characters in the middle > RF> of a string. RM>What is the faster pure QB way of finding ASC values in the middle of the >string? It sure would help me out.. Integer Array?? Take this apart...it's an old test piece from some instr$ and mid$ and asc(mid$,x) trials. You should be able to adapt it to your needs. You can change it to a function that return single asc values given the work$ and a position, or scan the length of a string as shown below. It's comparable in speed with instr$ (fast) for finding the position of a single character and much faster than ASC(MID$,Position%) for returning the ascii value in position%. defint a-z OPEN "TEST" FOR INPUT AS 1 OPEN "TEST.OUT" FOR OUTPUT AS 2 SEARCH%=101 replace%=102 FOR R= 1 TO LOF(1) \4096 WORK$=INPUT$(4096,1) DEF SEG=VARSEG(Work$) S=SADD(WORK$) FOR j = Position% TO LEN(work$)-1 X=PEEK(S+J) IF X=SEARCH% THEN POKE S+J,REPLACE% NEXT PRINT #2,work$; NEXT YLEN=LOF(1) MOD 4096 Y$=INPUT$(YLEN,1) DEF SEG=VARSEG(Y$) S=SADD(Y$) FOR j = Position% TO LEN(Y$)-1 X=PEEK(S+J) IF X=SEARCH% THEN POKE S+J,REPLACE% NEXT PRINT #2,Y$; Rob * OLX 2.2 * Pick another tablet Moses. This time don't show it to Me --- WM v2.06/92-0020 * Origin: The Purple Rose of Cairo, Pok NY US (914)473-1697(1:272/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