HP3000-L Archives

July 1995, Week 1

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:
Steve Elmer <[log in to unmask]>
Reply To:
Steve Elmer <[log in to unmask]>
Date:
Wed, 5 Jul 1995 21:26:55 GMT
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
Jeff Vance ([log in to unmask]) wrote:
: Hi All,
 
: Usage:
 
:   search_str[start] is searched looking for a word.  Leading word delimiters
: are
:   skipped.  Once the nth word is found (default is 1st) it is functionally
:   returned.  If the rtn_var parameter is passed then it is set to the index
:   of the delimiter that terminated the extracted word.
 
: Example:
 
:    setvar buffer input()
:    setvar i 1
:    while i <= len(buffer) do
:       setvar next_word word(buffer,i,,i)
:       if next_word = "..." then ...
 
comment: don't forget the increment!
        setvar i i+1
 
:    endwhile
 
This loop doesn't work the way you think it does based on the description.
If buffer = "a b cd efg", then each iteration would get the following values:
 
comment index 1, word 1
        a
comment index 2, word 2
        cd
comment index 3, word 3
        efg
comment index 4, word 4
        ???  what comes back when there is no such word?
 
It would work better if you left the index at 1, but when should the loop
terminate?
 
It seems to me that the function should return a null string when it can't
find the expected word.  The the loop could look like this:
 
setvar buffer input()
setvar i 1
while setvar(nextword, word(buffer,1,,i) <> "" do
  if next_word = "..." then ...
endwhile
 
The index is still a useful parameter if you've skipped over some portion
of the input doing something else.
 
: I am also planning on adding a word replace function.
 
How about a word count function too?
 
Steve

ATOM RSS1 RSS2