Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion wordposAtIndex() / wordAtIndex(): find the number of the word at a given index position

Received: by 10.66.81.202 with SMTP id c10mr2321417pay.40.1346185800778;
        Tue, 28 Aug 2012 13:30:00 -0700 (PDT)
Received: by 10.224.176.203 with SMTP id bf11mr9578368qab.4.1346185800612;
        Tue, 28 Aug 2012 13:30:00 -0700 (PDT)
Received: by 10.52.156.18 with SMTP id wa18mr2780418vdb.9.1346185800591; Tue,
 28 Aug 2012 13:30:00 -0700 (PDT)
Path: a5ni21712pbv.0!nntp.google.com!news2.google.com!r1no25317629qas.0!news-out.google.com!da15ni48885608qab.0!nntp.google.com!r1no2617745qas.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: comp.lang.rexx
Date: Tue, 28 Aug 2012 13:30:00 -0700 (PDT)
In-Reply-To: <b52b3469-e68d-4fa1-bd9f-5568ab296ae7@googlegroups.com>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=77.170.189.123;
 posting-account=tp3KYQoAAABrT94ut8Ka_zu08l2J-ent
NNTP-Posting-Host: 77.170.189.123
References: <81a1c884-036c-4b03-bfb9-1dafa40416b3@googlegroups.com> <b52b3469-e68d-4fa1-bd9f-5568ab296ae7@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1f048df4-266f-499a-990a-c30b122aff9d@googlegroups.com>
Subject: Re: wordposAtIndex() / wordAtIndex(): find the number of the word at
 a given index position
From: muk...@gmail.com
Injection-Date: Tue, 28 Aug 2012 20:30:00 +0000
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

thanks for the code bits.=20

Regarding the case when the index falls on a space character '20'x (a case =
I would normally not expect, but...) I would argue that the function should=
 return a value indicating the absence of a word, e.g. 0. Same would apply =
to a tab character '09'x, to stay compliant to the rexx definition of a whi=
tespace.

So in the preceding example, an if-statement would probably do the trick:

if substr(yyy,1,1)=3D=3D' ' | substr(yyy,1,1)=3D=3D'09'x then=20
  return 0
else
  return words(left(yyy,n))

/**/  parse arg n .;   if n=3D=3D'' then n=3D17
> yyy=3D'Georg Friedrich H=E4ndel, a great componist (sic)'
> say '         1         2         3         4       '
> say '12345678901234567890123456789012345678901234567'
> say yyy
> say
> say 'word index at' n "is" words(left(yyy,n))
>=20
> ____________________________ Gerard Schildberger