HP3000-L Archives

October 2001, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"VANCE,JEFF (HP-Cupertino,ex1)" <[log in to unmask]>
Reply To:
VANCE,JEFF (HP-Cupertino,ex1)
Date:
Tue, 23 Oct 2001 10:52:36 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (42 lines)
> i've got a simple little text file with two pieces of
> information on each record.  the first 'word' (piece of
> information) could be considered as a key value.  that is --
> another process will be examining this file looking for a
> match on the first field.  (and btw, since i know the
> data....most of the time the match will fail....).  if a
> match is found, i need the 2nd 'word' (piece of information)
> placed into a ci variable.

Here's a rough sketch that has *not* been tested at all:

PARM file, key, rtnvar=info, entry=main
# Search "file" for "key" and return info in "rntvar".
# File format is:
#   key1 info1
#   key2 info2
#   ...
#
if '!entry' = 'main' then
   setvar !rtnvar ""
   # verify "file" exists, etc... then
   xeq !hpfile !file, !key, !rtnvar entry=read <!file
   # cleanup etc...
   return

elseif '!entry' = 'read' then
   # input redirected to the "file" parm
   setvar cnt finfo(hpstdin,'eof')
   while setvar(cnt,cnt-1) >= 0 and &
         word(setvar(rec,input())) <> "!key" do
      # assumes a string key and case sensitive...
   endwhile
   if cnt >= 0 then
      # match
      setvar !rntvar word(rec,,2)
   endif
   return
endif

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2