Assigning same value to multiple variables

This is a discussion on Assigning same value to multiple variables within the REXX forums in Programming Languages category; Has the ability to assign the same value to several variables been added to ooRexx anywhere along the way? My bet is no (on the basis that I tend to lose all bets, and I want to lose this one). So instead of: A=1; B=1 I could use something like: A,B = 1 I get around this using the mechanism: Parse value 1 1 with A B /* But it's not very elegant */ /* And doesn't handle blanks */ -- Steve Swift http://www.swiftys.org.uk/swifty.html http://www.ringers.org.uk...

Go Back   Application Development Forum > Programming Languages > REXX

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 05-31-2008, 03:44 AM
Steve Swift
Guest
 
Default Assigning same value to multiple variables

Has the ability to assign the same value to several variables been added
to ooRexx anywhere along the way? My bet is no (on the basis that I tend
to lose all bets, and I want to lose this one).

So instead of:
A=1; B=1

I could use something like:
A,B = 1

I get around this using the mechanism:

Parse value 1 1 with A B /* But it's not very elegant */
/* And doesn't handle blanks */

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Reply With Quote
  #2  
Old 05-31-2008, 08:13 AM
Gil Barmwater
Guest
 
Default Re: Assigning same value to multiple variables

Steve Swift wrote:
> Has the ability to assign the same value to several variables been added
> to ooRexx anywhere along the way? My bet is no (on the basis that I tend
> to lose all bets, and I want to lose this one).
>
> So instead of:
> A=1; B=1
>
> I could use something like:
> A,B = 1
>
> I get around this using the mechanism:
>
> Parse value 1 1 with A B /* But it's not very elegant */
> /* And doesn't handle blanks */
>

But this DOES handle blanks:

Parse value 'two words' with A 1 B 1 C
Reply With Quote
  #3  
Old 05-31-2008, 01:40 PM
Three Lefts
Guest
 
Default Re: Assigning same value to multiple variables

On Sat, 31 May 2008 08:44:37 +0100, Steve Swift
<Steve.J.Swift@gmail.com> wrote:

>Has the ability to assign the same value to several variables been added
>to ooRexx anywhere along the way? My bet is no (on the basis that I tend
>to lose all bets, and I want to lose this one).


Let's see. You are betting against this feature having been added
because (a) you want the feature added, (b) you tend to lose all best,
and (c) you believe that whatever cosmic force it is that casues you
to lose bets is powerful enough to cause the feature to materialize
because you bet against it. Right?

How often does this strategy work for you?

>So instead of:
>A=1; B=1
>
>I could use something like:
>A,B = 1


How about a=1; b=a?

>I get around this using the mechanism:
>
>Parse value 1 1 with A B /* But it's not very elegant */
> /* And doesn't handle blanks */


Ugh & yuck. Now I know why you lose so many bets. ;-)
Reply With Quote
  #4  
Old 05-31-2008, 03:22 PM
Porter Smith
Guest
 
Default Re: Assigning same value to multiple variables


> I could use something like:
> A,B = 1
>


varList = "A B"
Do While varList ^= ''
Parse var varList nextVar varList
Interpret nextVar " = 1"
End


Reply With Quote
  #5  
Old 05-31-2008, 07:42 PM
Shmuel (Seymour J.) Metz
Guest
 
Default Re: Assigning same value to multiple variables

In <Xns9AAF9C591C6A5myport2000yahoocom@127.0.0.1>, on 05/31/2008
at 02:22 PM, Porter Smith <my_port_2000@yahoo.com> said:

>varList = "A B"
>Do While varList ^= ''
> Parse var varList nextVar varList
> Interpret nextVar " = 1"
>End


Why use interpret when value() will do the job?

--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spamtrap@library.lspace.org

Reply With Quote
  #6  
Old 05-31-2008, 10:35 PM
Porter Smith
Guest
 
Default Re: Assigning same value to multiple variables

Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid> wrote in
news:4841f08b$1$fuzhry+tra$mr2ice@news.patriot.net :

> In <Xns9AAF9C591C6A5myport2000yahoocom@127.0.0.1>, on 05/31/2008
> at 02:22 PM, Porter Smith <my_port_2000@yahoo.com> said:
>
>>varList = "A B"
>>Do While varList ^= ''
>> Parse var varList nextVar varList
>> Interpret nextVar " = 1"
>>End

>
> Why use interpret when value() will do the job?
>

Because I didn't think of it?
Reply With Quote
  #7  
Old 06-02-2008, 11:27 AM
Steve Swift
Guest
 
Default Re: Assigning same value to multiple variables

Three Lefts wrote:
> How about a=1; b=a?


Yes, that will be better than what I have right now, which is:
DT.0 = 5
DV.0 = 5
Whenever I change the 5 to a 6, I have to change both, and it causes
problems if I forget.

>> Parse value 1 1 with A B /* But it's not very elegant */

/* And doesn't handle blanks */
> Ugh & yuck. Now I know why you lose so many bets. ;-)


The original challenge was to set two variables in one statement, during
the early days of REXX development. It might have come from MFC, but I
have no way to confirm this.

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Reply With Quote
  #8  
Old 06-02-2008, 11:37 AM
Rich Greenberg
Guest
 
Default Re: Assigning same value to multiple variables

In article <48455de8@news.greennet.net>,
Steve Swift <Steve.J.Swift@gmail.com> wrote:

>Yes, that will be better than what I have right now, which is:
> DT.0 = 5
> DV.0 = 5
>Whenever I change the 5 to a 6, I have to change both, and it causes
>problems if I forget.


For your specific case (not in general) I would suggest:

DT.0 = 5
DV.0 = DT.0

--
Rich Greenberg N Ft Myers, FL, USA richgr atsign panix.com + 1 239 543 1353
Eastern time. N6LRT I speak for myself & my dogs only. VM'er since CP-67
Canines:Val, Red, Shasta & Casey (RIP), Red & Zero, Siberians Owner:Chinook-L
Retired at the beach Asst Owner:Sibernet-L
Reply With Quote
  #9  
Old 06-02-2008, 12:44 PM
Allodoxaphobia
Guest
 
Default Re: Assigning same value to multiple variables

On Mon, 2 Jun 2008 15:37:09 +0000 (UTC), Rich Greenberg wrote:
> In article <48455de8@news.greennet.net>,
> Steve Swift <Steve.J.Swift@gmail.com> wrote:
>
>>Yes, that will be better than what I have right now, which is:
>> DT.0 = 5
>> DV.0 = 5
>>Whenever I change the 5 to a 6, I have to change both, and it causes
>>problems if I forget.

>
> For your specific case (not in general) I would suggest:
>
> DT.0 = 5
> DV.0 = DT.0


Or,
:
|Changeable_Value = 5
:
:
:
|DT.0 = Changeable_Value
:
:
:
|DV.0 = Changeable_Value

Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
38.24N 104.55W | @ config.com | Jonesy | OS/2
*** Killfiling google posts: <http://jonz.net/ng.htm>
Reply With Quote
  #10  
Old 06-02-2008, 06:33 PM
Pit Zyclade
Guest
 
Default Re: Assigning same value to multiple variables

Rich Greenberg schrieb:
> In article <48455de8@news.greennet.net>,
> Steve Swift <Steve.J.Swift@gmail.com> wrote:
>
>> Yes, that will be better than what I have right now, which is:
>> DT.0 = 5
>> DV.0 = 5
>> Whenever I change the 5 to a 6, I have to change both, and it causes
>> problems if I forget.

>
> For your specific case (not in general) I would suggest:
>
> DT.0 = 5
> DV.0 = DT.0
>


That is not was he will.

DT.0 = 5
DV.0 = DT.0

DT.0 = 6
say DV.0 DT.0

and you can see that DV.0 = 5 , not 6 !

Pit
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:15 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.