Article View: comp.os.os2.programmer
Article #3637Re: Rexx question
From: Pat Mueller
Date: Mon, 25 Jan 1993 22:52
Date: Mon, 25 Jan 1993 22:52
52 lines
1671 bytes
1671 bytes
>I'm doing a little Rexx programming and came upon the following:
>/* */
>
>line = "prpipgphptp"
>
>do while((n = pos("p", line)) \= 0)
> line = overlay(" ", line, n)
>end
>
>say line
> ...
>The output when this program is run is the following:
>
>prpipgphptp
>...
The construct
do while((n = pos("p", line)) \= 0)
while legal, probably doesn't do what you want it to. It compares
the variable "n" with the value of the pos() function call. The
resulting comparison (whose value is 0 or 1) is compared to 0.
Basically, rexx has no assignment operator that can be used within
expressions (like C does). Your second try is the way to do it.
When in doubt, insert a 'trace ?i' line at the top of your program
and you'll see all the gory details of statement evaluation. An
example follows:
4 *-* line = "prpipgphptp"
>L> "prpipgphptp"
+++ Interactive trace. TRACE OFF to end debug, ENTER to continue
6 *-* do while((n = pos("p", line)) <> 0)
>L> "N"
>L> "p"
>V> "prpipgphptp"
>F> "1"
>O> "0"
>L> "0"
>O> "0"
10 *-* say line
>V> "prpipgphptp"
prpipgphptp
If still in doubt, comp.lang.rexx is the best place to get answers
regarding rexx in general.
Patrick Mueller addr: pmuellr@vnet.ibm.com
IBM Cary, North Carolina phone: 919-469-7242
Technical Details
Message-ID:
<19930125.150906.802@almaden.ibm.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.comShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.com From: pmuellr@vnet.ibm.com (Pat Mueller) Message-ID: <19930125.150906.802@almaden.ibm.com> Date: Mon, 25 Jan 93 17:52:01 EST Newsgroups: comp.os.os2.programmer Subject: Re: Rexx question Lines: 52