Qbasicnews.com

Full Version: Mid$ extraction question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I while ago Dr. Davenstein gave me this codeSadi modded it a little bit as needed)

Code:
GetInput:
CLS
INPUT "Enter Hex code"; TS$



FOR X = 1 TO LEN(TS$)
Error1 = ASC(MID$(TS$, X)) < 48 OR ASC(MID$(TS$, X)) > 57
Error2 = ASC(MID$(TS$, X)) < 65 OR ASC(MID$(TS$, X)) > 70
IF Error1 AND Error2 THEN
  PRINT MID$(TS$, X, 1); " is an invalid character!"
  SLEEP 1
  GOTO GetInput
END IF
NEXT


PRINT "&H" + S$


Say I enter this in the TS$

D080???? 00100000
1080???? 00000###

How can I make a function that searches for text other than the characters 0-F and return it in a string? The above code works, (PRINT MID$(TS$, X, 1); " is an invalid character!" ) but it only returns one character of the text that isnt hex.

What I want it to do is return ????, ????, and ### all in different string variables. Thanks!
Trace the logical flow of your program. In particular, look at where the GOTO is. Big Grin
Dont use GOTOs! And yes, as Nek said *you* trace the flow of the program =P