Re: Indexing and searching
On 9 Mar 2001, at 21:42, Tony Steward wrote:
> Hi All,
> I have a complicated indexing problem that I have no idea how to tackle.
>
> 1st some background, I'm a locksmith and we often cut keys to code. Which
> means that we
> take a number stamped on a lock or provided to us by the manufacturer, I then
> go to code
> books or to another code program to lookup the cutting pattern of the key.
>
> Ok now the fun begins.
> Code series FA1 - FA2700 means there are 2700 codes and the program user may
> type "FA0001"
> or "FA1" and iether way come up with the same answer. This doesn't look too
> hard but when
> this code series is put into a data base with 10,000 others it gets harder.
> I'll list a
> few for you to get the idea.
>
> PROFILE
> SERIES
> MINIMUM
> MAX
> MASK
> KEYBLANK
>
> T......
> 1234
> T111111
> T444444
> 0111111
> FO21P
>
> TC....
> 1-1000
> TC1
> TC1000
> 001111
> FO9
>
> TX....
> 1-1859
> TX1
> TX1859
> 001111
> FO9
>
> ER...
> 1-195
> ER1
> ER195
> 00111
> FOT3
>
> ER...
> 501-695
> ER501
> ER695
> 00111
> FOT3
>
> ER...
> 101-295
> ER101
> ER295
> 00111
> FOT3
>
> .....
> 0789
> 00000
> 99999
> 11111
> HON24R
>
> .....A/Z
> 04689
> 00000A
> 99999Z
> 111110
> NE20
>
> .....F.
> 04689
> 00000F0
> 99999F9
> 1111101
> NE39
>
>
>
> Row 1 all codes start with "T" followed by 6 digits but can only use digits
> listed in
> series column (outlined in mask). Row 2 all codes start with "TC" followed
> numerically
> from 1 to 1000. IE TC1, TC2, TC3 and so on to TC1000. Row 7 all codes conatin
> 5 digits but
> can only use digits listed in series column. Row 8 all codes contain 5 digits
> and one
> letter.
>
> How can a take a users input of TC767 and list all code series (records) that
> may contain
> TC767 given there may be another code series that is from TC7000 to TC9000
> which is
> similar but not correct. It is also possible for a user to type TC0767 Or Take
> a users
> input of 48644D and find its row.
Well, i lost the formatting of the records you included, but at first glance
this seems
easy. The series all start with A-Z chars, and end in 0-9-A-Z, but need not
permit a
zero after the beginning A-Z chars.
<pseudocode>
So read in the line,
index = 0
while find(line[index],alphaset) do
inc index
prefix = prefix & line[index]
end while
suffix = line[index..length(line)]
strip the zeros
line = prefix & suffix
</pseudocode>
then loop and find(database[loop],line) the line in a database built by the same
rules in
the pseudocode above. The first example you gave would look like this in the
start of
the database:
database = {
{ next line },
etc,
}
If there is a range you are interested in, then in the loop thru the database,
test the
field (called a subsequence) to see if it is the proper range:
integer PROFILE PROFILE=1
integer SERIES SERIES=2
integer MINIMUM MINIMUM=3
integer MAX MAX=4
etc...
if ( line > database[loop][MINIMUM] ) and
( line < database[loop][MAX] ) then
-- do something, such as.....
for dbindex = PROFILE to KEYBLANK do
puts(1,database[dbindex]&"\n")
end for
end if
or since my pseudocode broke line into suffix and prefix already, you might use
suffix
instead of line, as appropriate.
Kat,
could have misunderstood the problem.
|
Not Categorized, Please Help
|
|