You made me study Pointers now, still I will compare the two your's and my tally routine to see wich is actually faster

Wondering if the select case is fast enough?
MM a nice example for me to study thanks for your effort.
%CHAR_LOW = 33? ' high and low ASC() of searched characters %CHAR_HIGH = 255? ' TRUE ==> The string 'S DOES CONTAIN at least one character in range %CHAR_LOW to %CHAR_HIGH ' which occurs more than 'limit' times ' FALSE==> It don't. FUNCTION DoesStringContainMoreThan (s AS STRING, BYVAL limit as LONG) AS LONG LOCAL pChar AS BYTE PTR , nOccur() AS LONG LOCAL lStr AS LONG, I AS LONG lStr = LEN(S) ' number of characters to be inspected pChar = STRPTR (S) ' point at first character REDIM nOccur (%CHAR_HIGH) ' array big enough to support %CHAR_HIGH FOR I = 1 TO lStr SELECT CASE AS LONG @pChar CASE %CHAR_LOW TO %CHAR_HIGH INCR nOccur (@pChar) IF nOccur(@pChar) > limit THEN ' it happened, we can stop looking now. FUNCTION = %TRUE EXIT FUNCTION END IF END SELECT INCR pChar ' point to next character of S NEXT FUNCTION = 0 ' if we get here it didn't happen END FUNCTION
WHILE NOT EOF(1) LINE INPUT #1, a$ FOR I = 33 TO 255 Z(i) = 0 Z(i) = TALLY (a$, CHR$(I)) NEXT ARRAY SCAN Z(33), >5, TO R IF R THEN ....... WEND
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: