Re: wildcard usage
On Sat, 10 Apr 1999 13:37:26 -0400, Norm Goundry <bonk1000 at HOTMAIL.COM>
wrote:
>got a bit of a thing that has been driving me slowly insane since I first
>started using EU. I have tried every permutation of code to create a
>'wildcard' method to substitute for many lines of branching to strings of
>data; question: is it possible to turn this...?
>
> --string 1
> a1={"cat","dog","mouse"}
> --string 2
> a2={"chicken","duck","cow"}
>
> input=x string_to_fetch="a" & x
> --where string_to_fetch is executable in the same way
> --that either string_to_fetch=a1 or string_to_fetch=a2 is
>
>-- I know that this isn't legal code, but perhaps you get the idea. I am
>polishing up some of the code of a huge database written in EU and this
>would be extremely useful if it is possible to do such a thing. I could do
>it on my old Amiga when using AMOS Basic. Any ideas that I haven't thought
>of yet?, any thing that works?, any help and suggestions for this will be
>mightly appreciated. Note: I don't wish to hear any lecturing about this
>bringing on the nightmare of 'speghetti-code'... if it is doable it can be
>usable.
>thanks Norm
I'm not really sure what you are trying to do here. but from what I see.
You are wanting to use match().
something like.
function fetch_strings(sequence search_for, sequence search_in)
integer found
sequence temp
temp = {}
for A = 1 to length(search_in) do
found = match(search_for, search_in[A])
if found then
temp = append(temp, search_in[A])
end if
end for
return temp
end function
sequence a1, a2, f1, f2, f3
a1 = {"cat", "bird", "rabbit"}
a2 = {"frog", "dog", "snake"}
f1 = fetch_strings("a", a1)
--f1 now equals {"cat", "rabbit"}
f2 = fetch_strings("og", a2)
--f2 now equals {"frog", "dog"}
f3 = fetch_strings("a", a2)
--f3 now equals {"snake"}
I hope this helps.
Lucius L. Hilley III
http://www.cdc.net/~lhilley -- a member of the Euphoria webring.
|
Not Categorized, Please Help
|
|