Hi,
I find the following function useful:
<hansl>
function scalar arrindex(strings S, string s)
loop i = 1..nelem(S) -q
if S[i] == s
out = i
return out
endif
endloop
return 0 # no match was found
end function
strings checks = defarray("hey", "ho", "let's",
"go")
eval arrindex(checks, "go")
eval arrindex(checks, "No go")
</hansl>
(The "out=i / return out" redundancy is due to the bug I just posted.)
That way you can have an array of strings serving as labels for an
accompanying array of matrices, and you can pick the right matrix in the
array by searching the strings array for a match.
Dreaming on in terms of syntax, it would be wonderful if one could loop
over an array like this: "loop foreach i S", but it would of course be
just syntactic sugar.
thanks,
sven
Show replies by date