QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

Nice excercise

February 10 2012 at 11:43 AM
lawgin  (no login)


Response to Challenge: Team Roster in a Compressed Database

 

Your challenge didn't ask for permanent storage of the data or input filtering, so I didn't include it.



DIM p$(20)
DO
s = 1
PRINT
INPUT "Player's Name (ENTER when done)"; nam$
IF nam$ = "" THEN EXIT DO
DO
sp = INSTR(s, nam$, CHR$(32))
IF sp THEN nam$ = LEFT$(nam$, sp - 1) + MID$(nam$, sp + 1)
s = sp + 1
LOOP WHILE sp > 0
INPUT "Player's Number"; num$
p$(n) = num$ + nam$
n = n + 1
LOOP

CLS
DO
PRINT
INPUT "Search String (ENTER when done)"; ss$
IF ss$ = "" THEN EXIT DO
ss = VAL(ss$)
FOR a = 0 TO n
IF (INSTR(p$(a), ss$) AND ss = 0) OR (INSTR(p$(a), ss$) AND VAL(p$(a)) = ss) THEN
rec$ = p$(a)
FOR k = 2 TO LEN(rec$)
v = ASC(MID$(rec$, k, 1))
IF v > 64 AND v < 91 AND MID$(rec$, k - 1, 1) >= "0" THEN
rec$ = LEFT$(rec$, k - 1) + " " + MID$(rec$, k)
k = k + 1
END IF
NEXT k
PRINT rec$
END IF
NEXT a
LOOP
END





 
 Respond to this message   
Responses

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement