04-26-2024, 01:49 PM
(04-26-2024, 01:38 AM)Pete Wrote: @bplus
I think it was some five or six years ago I started working on a C/C++keyboard input routine. I finished it, and from a few of the articles I read discovered that it is supposed to be faster to manipulate an existing string than to add to a string. Now for the functions you are using, I modified both INSTR() approaches to work in that manner. The first does unique letters, the second displays multiple instances of any duplicated letters, which I think was the one you were testing with. Now it may be faster, but to achieve the same results, another counting variable needed to be added and the initial string to apply mid$() had to be created. So the question of any actual speed improvements is uncertain.
If you'd like to test it, just replace whichever one is appropriate in your timed system and see how it performs...
Code: (Select All)a$ = "uncopyrightable"
Print ">"; petecode1$(a$); "<"
Function petecode1$ (a$)
rtn$ = Space$(26)
For i% = 97 To 122
seed% = InStr(a$, Chr$(i%))
If seed% Then
j% = j% + 1
Mid$(rtn$, j%) = Chr$(i%)
End If
Next
petecode1$ = RTrim$(rtn$)
End Function
Code: (Select All)a$ = "uncopyrightaabbble"
Print ">"; petecode2$(a$); "<"
Function petecode2$ (a$)
rtn$ = Space$(Len(a$))
For i% = 97 To 122
seed% = InStr(a$, Chr$(i%))
While seed%
j% = j% + 1
Mid$(rtn$, j%) = Chr$(i%)
seed% = InStr(seed% + 1, a$, Chr$(i%))
Wend
Next
petecode2$ = RTrim$(rtn$)
End Function
Pete
ok looks like i will be comparing anacode with the mid$ mod to petecode with mid$ mod
sounds interesting, how much imporvment for 25,000 word file (almost), done 25 times, with mid$
good experiment alright!
b = b + ...