Ron Wuerth wrote:
> Now, question...if I'm reading your scripts correctly,
> in your return variable (assuming there is a match)
> on the "search" script where you do the following:
>
> setvar !_s_return_var "![_ma_rec!bin_return]"
>
> aren't you just putting a line like the following into
> the "_s_return_var"...
>
> "1 one" #(no quotes)
yes, the whole record for the matched key is 'returned'
> I know you can play with things like "str" to pull out
> the "one" but I was under the impression you really
> wanted to input the key, and get ONLY the value
> back ready to go.
well, for my example, yes. but for general purpose needs, the 'str' function
is needed.
> I bring this up because I finally got "smart" and did a
> "help functions" at the CI. By doing that I rediscovered
> the "word" function.
(you do know the whole purpose of this exercise is to get everyone digging into
'help', right? :-)
> 1. The obvious, you can now return JUST the value you're
> looking for.
...and my original prototype (that never really saw the light of day) did just
that.
> 2. If used correctly within your "mkarray" script, you can
> accept data that is NOT ordered, misaligned, and no need
> for even a binary search, because you have direct access
> once the array is created.
hmmm.... that's right :-)
> to this:
> =========================
> 'mkarray'
> setvar _ma_eof finfo(HPSTDIN,"eof")
> while setvar(_ma_eof,_ma_eof-1) >= 0
> input _ma_rec
> setvar _ma_key word("!_ma_rec",,1) # <=== is key only [added]
> setvar _ma_val!_ma_key word("!_ma_rec",,2) # <=== is value only
> endwhile
> ======================
assuming (and that's that dangerous thing :-) the data is word-able, then yes.
> We use the ACTUAL "key" numeral (the first data item
> in the rec) as the array index, (which makes it more like
> a hash).
yes.... what if the key isn't numeric? i think we're still ok.....?
> Now to search for a specific value to use IF available,
> instead of the "binsrch" routine you have direct access
> as follows:
all-in-all -- you've made several excellent observations! - d
--
Donna Garverick Sr. System Programmer
925-210-6631 [log in to unmask]
>>>MY opinions, not Longs Drug Stores'<<<
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|