[Info-vax] Looking for some text search ideas
David Froble
davef at tsoft-inc.com
Sat Sep 27 19:26:09 EDT 2014
Jan-Erik Soderholm wrote:
> I'm quite sure that regexp is *not* the answer for actual issues.
> It is not that complex, and you'd put the burdon on the user to
> come up with the actual regexp. That does not work, of course.
> I'm sure it will all end up in some simply test search
> sequantial over the data/file/table...
>
> Jan-Erik.
It's already in production.
I didn't check the code, but I'd guess it's something like:
Assuming the data is in 3 arrays Mfg$(), Part$(), and Desc$()
And the list is a RECORD variable array called List with elements Mfg$
and Part$
And the search masks are Mask1$, Mask2$, and Mask3$
! Loop through the array
For I% = 1% to MaxRec%
! If a mfg code is specified, skip unless a match
Iterate if Mfg$ <> "" and Mfg$ <> MFG$(I%)
! Search the description
Iterate Unless InStr( 1% , Desc$(I%) , Mask1$ ) &
Or Instr( 1% , Desc$(I%) , Mask2$ ) &
Or Instr( 1% , Desc$(I%) , Mask3$ )
! Found one, add to list
J% = J% + 1%
List(J%)::Mfg$ = Mfg$(I%)
List(J%)::Part$ = Part$(I%)
Next I%
Now, I'd want to allow for a variable number of search masks, and
respect for "AND" and "OR" which would mean a bit more code, but the
example shows that if you got enough memory and CPU it's a rather simple
thing to do.
Where I'd look for some efficiency is in checking the description for
multiple masks in one pass, but, I don't think that would be possible,
even if some tool made it seem it was doing it. When you get down to
the actual machine instructions, I'm betting that it would do one mask
at a time.
More information about the Info-vax
mailing list