Ok, Meg, your approach sounds ingenious. I've never used PSET and POINT commands, so I don't really understand how it's supposed to work.

The fact is, however, that it doesnÂ´t work. It only likes small code numbers less than 500. I made several versions of the VALID.TXT file but any valid number greater than 400 is marked as invalid by your program. Must be a minor coding error. Or maybe I need to add some switch to the BC compiler.

*****

Yeah I had a "480" instead of a "640"; just a typo. All fixed, now. You don't need any fancy switches or anything. It just uses the screen to store the information, which means you don't need to create any additional arrays.

The code is pretty straightforward. Open up the data file, read in the values, and plot points on the screen:

i.e.

if the number read in = 0, plot a point at (0, 0)

if the number read in = 1, plot a point at (1, 0)

if the number read in = 639, plot a point at (639, 0)

if the number read in = 640, plot a point at (0, 1)

and so forth..

then, when the user enters codes, it just uses the POINT command to see whether the pixel which corresponds to that number has been lit up or not.

*peace*

Meg.

MEG:

Fantastic, It works 100%. Congratulations. Brilliant idea.

I think we'll wait a day to see if Aga comes up with a solution, and then we'll declare a winner, which will be tough.

*****

Signed integers are so much nicer sometimes...

Blah.. I might not post anything... if i convert my array to LONG, it won't go as fast....

Aga, don't be concerned with speed for this. We're looking for design and simplicity.

You must take into consideration that this program has a user interface. So, the user is not going to notice the difference of a few microseconds.

*****

My entry. Uses longs! I know,

BAD!

Code:

`'Is this BLITZTASTIC OR WHAT??!?!?`

DECLARE FUNCTION validate.all% (file1$)

DECLARE FUNCTION num.exists% (n&)

DECLARE SUB load.valid.nums (file1$)

DIM SHARED num.max AS LONG, num.max2 AS LONG: num.max = 100000: num.max2 = num.max \ 16

DIM SHARED huge.array(1 TO num.max2) AS LONG

DIM SHARED bit2(0 TO 15) AS LONG

DIM SHARED num.amount AS INTEGER: num.amount = 20000

FOR I% = 0 TO 15: bit2(I%) = 2 ^ I%: NEXT I%

CLS

'OPEN "valid.txt" FOR OUTPUT AS #1

'FOR I% = 1 TO 20000

'a$ = LTRIM$(STR$(INT(RND * 100000)))

'PRINT #1, a$

'NEXT I%

'CLOSE

'SYSTEM

load.valid.nums ("valid.txt")

t1# = TIMER

PRINT validate.all%("valid.txt")

t2# = TIMER: PRINT "Time for"; num.amount; "values to be processed:"; t2# - t1#; "seconds."

'use num.exists%(n&) for individual numbers..

DO

INPUT n&

IF n& > 99999 THEN PRINT "Number bigger than 99999..."

IF n& < 0 THEN PRINT "Number smaller than 0..."

IF num.exists%(n&) THEN PRINT "Number exists!" ELSE PRINT "Number doesn't exist.."

LOOP

SUB load.valid.nums (file1$)

enter.char$ = CHR$(13): a1$ = " ": a2$ = " ": num1$ = "": num2% = 0

OPEN file1$ FOR BINARY AS #1

j% = 1: FOR I% = 1 TO num.amount

num1$ = ""

GET #1, , a1$: IF a1$ = enter.char$ THEN GOTO v2

IF INSTR("0123456789", a1$) = 0 THEN GET #1, , a1$: GOTO v2

FOR j% = 1 TO 4

num1$ = num1$ + a1$

GET #1, , a1$: IF a1$ = enter.char$ THEN GOTO v1

IF INSTR("0123456789", a1$) = 0 THEN GET #1, , a1$: GOTO v2

NEXT j%

num1$ = num1$ + a1$

GET #1, , a1$

v1: IF a1$ <> enter.char$ THEN GET #1, , a1$: GOTO v2

num2& = VAL(num1$)

k% = num2& MOD 16

j% = num2& \ 16 + 1

temp& = huge.array(j%)

IF (temp& AND bit2(k%)) = 0 THEN huge.array(j%) = temp& + bit2(k%)

v2: GET #1, , a1$

NEXT I%

CLOSE

END SUB

FUNCTION num.exists% (n&)

k% = n& MOD 16

j% = n& \ 16 + 1

IF (huge.array(j%) AND bit2(k%)) THEN num.exists% = -1

END FUNCTION

FUNCTION validate.all% (file1$)

is.valid% = -1

enter.char$ = CHR$(13): a1$ = " ": a2$ = " ": num1$ = "": num2% = 0

OPEN file1$ FOR BINARY AS #1

j% = 1: FOR I% = 1 TO num.amount

num1$ = ""

GET #1, , a1$: IF a1$ = enter.char$ THEN GOTO v2b

IF INSTR("0123456789", a1$) = 0 THEN GET #1, , a1$: GOTO v2b

FOR j% = 1 TO 4

num1$ = num1$ + a1$

GET #1, , a1$: IF a1$ = enter.char$ THEN GOTO v1b

IF INSTR("0123456789", a1$) = 0 THEN GET #1, , a1$: GOTO v2b

NEXT j%

num1$ = num1$ + a1$

GET #1, , a1$

v1b: IF a1$ <> enter.char$ THEN GET #1, , a1$: GOTO v2b

num2& = VAL(num1$)

k% = num2& MOD 16

j% = num2& \ 16 + 1

temp& = huge.array(j%)

IF (temp& AND bit2(k%)) = 0 THEN is.valid% = 0

v2b: GET #1, , a1$

NEXT I%

CLOSE

validate.all% = is.valid%

END FUNCTION

Aga, Congratulations, it works!

However, it looks a bit complicated.

One small observation. On user input it allows leading, embedded, and trailing blanks on the numbers. Not exactly "clean", but that's my opinion.

*****

Arr! I thought we already discussed that it removes all of that? aRr!!!!

CODE VALIDATION CHALLENGE FINAL RESULTS:

First Place: MEG. Brilliant solution and concise implementation.

Tied for Second: ANTONI and BLITZ. Excellent solutions and implementations.

Third: AGA. Very good, working solution.

Fourth: STERLING. Participated.

*****