Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two Questions
#1
First Question is:

If there's a character in the string that I don't want, how do I tell user that they have to input a new string? The valid characters that can be in the string are hex characters, numbers 1 through 9 and letters A through F. And the string must be 8 characters long. Say, the user accidently puts the letter g or something other than the above how could I detect that and tell the user that it's invalid?

Second Question is:

Whenever I write files I always overwrite the whole file each time I write it again. How can I not overwrite the file, and keep the data that was already in there unchanged?

As always, thanks for any help! Big Grin
quote="na_th_an"]
Greenday, Spice Girls... Can you tell the difference?
[/quote]
Reply
#2
If you use INPUT S$, you'll have to wait for the user to press enter before you can do anything. Then you could just do something like this...

Code:
GetInput:
CLS
INPUT "Enter Hex code"; TS$
S$ = MID$(TS$, 1, 8)


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


PRINT "&H" + S$


The APPEND keyword in an OPEN statement specifies that the file is
to be opened for sequential access, and sets the file pointer to the
end of the file. PRINT # or WRITE # statements then append to (extend) the file.
Reply
#3
Wow dude that's really helpful! Thanks alot!
quote="na_th_an"]
Greenday, Spice Girls... Can you tell the difference?
[/quote]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)