Re: number match selection
On way is to use bit flags to keep track of what numbers have been guessed:
GUESSES = %01111110 ' We're not using bit 0 because you can't guess 0
On each guess, GUESSES.[Numberguessed] = 0. If 3 is guessed GUESSES.3 = 0 and GUESSES becomes %01110110...
To determine the lowest number and return it
IF GUESSES = 0 then all numbers have been guessed
For LP = 1 to 6
IF GUESSES.LP = 1 Then
LP is the lowest number left
Endif
Next LP
I'm not advertising this as suitable code, rather sort of pseudo-code to illustrate the concept.
Re: number match selection
thanks for that - sometime i get caught up in what i am doing and cant think of easy answer
here is simulated code ill try,my real codes has multi indexed variables ,but the principle is correct
the end value shown needs to be the lowest number between 1 -6 for my use , 0 is ok as it show there is no " index slots" Left and is used to determine if more index slots are added later
Code:
z = 0
X = 0
index_slot = 0
for z = 0 the index ' test to array length
if value1(z) & $F0 = value2 then ' match upper nibble
for X = 1 to 6
Y = value1(z) & $0F ' get lower nibble value into Y
if X = Y then Index_slot.X = 1 ' put a 1 into the bit location representing values 1- 6 of index_slot that have been used
next X
next z
x = 0
for X = 6 to 1
if index_slot.X >> X = 1 then index_slot = X ' show the lowest value available index slot for use
next X
Re: number match selection
i get a " bad token" error with this , what is the correct way to do it again ?
Code:
for X = 6 to 1
if index_slot.X >> X = 1 then index_slot = X ' show the lowest value available index slot for use
next X
Re: number match selection
Code:
for X = 6 to 1
if index_slot.0[X] >> X = 1 then index_slot = X ' show the lowest value available index slot for use
next X
Re: number match selection
Don't forget to add a" STEP -1" to your "FOR" line, unnecessary when counting up, but required to decrement your loop variable