🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #3623

Rexx question

#3623
From: Tim Francis
Date: Mon, 25 Jan 1993 14:56
55 lines
1927 bytes
In article <1993Jan24.181958.6740@athena.mit.edu>,
jawetzel@athena.mit.edu (The Rottweiler) writes:
>
>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
>
>line = "prpipgphptp"
>
>n = pos("p", line)
>do while(n \= 0)
> line = overlay(" ", line, n)
> n = pos("p", line)
>end
>
>say line
>
>-------------------------------
>
>The output when this program is run is the following:
>
>prpipgphptp
> r i g h t
>
>My question is simple - is this a bug or a limitation of the
>Rexx programming language?  Or is it that I'm doing something
>wrong?
>
>						Jake

The problem is that REXX doesn't support assignment within conditional
expressions.  This can be seen fairly easily by running your program
with TRACE ?I  (I = show intermediate values)

  *-*   Do While ( ( n = pos('p', line) ) <> 0 );  My Comments
  >L>       "N"                                    n = 'N'
  >L>       "p"
  >V>       "prpipgphptp"
  >F>       "1"                                    pos('p',line) = 1
  >O>       "0"                                    (N = 1) = 0
  >L>       "0"
  >O>       "0"                                    (0 <> 0) = 0
  >>>       "0"

The key is the part (N=1), which is evaluated as a condition, whose
result is either 0 (FALSE) or 1 (TRUE).   -tim
Technical Details
Message-ID: <19930125.082123.510@almaden.ibm.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.com
References: <1993Jan24.181958.6740@athena.mit.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.com
From: francis@vnet.ibm.com (Tim Francis)
Message-ID: <19930125.082123.510@almaden.ibm.com>
Date: Mon, 25 Jan 93 09:56:59 EST
Subject: Rexx question
Newsgroups: comp.os.os2.programmer
References: <1993Jan24.181958.6740@athena.mit.edu>
Reply-To: francis@vnet.ibm.com
Organization: IBM Canada Lab, WorkFrame/2 development
Disclaimer: This posting represents the poster's views, not those of IBM
Lines: 55