IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

REXX - Adding variables


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
TGarcia

New User


Joined: 24 Jul 2021
Posts: 3
Location: United States

PostPosted: Sat Jul 24, 2021 9:09 pm
Reply with quote

Hello!

How can I add multiple variables from String?
ex:

a.1 = 'red apples'
a.2 = 'green apples'
a.3 = 'yellow bananas'
a.4 = 'red apples'
a.5 = 'yellow bananas'

desire output:
red apples 2
green apples 1
yellow bananas 2
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1314
Location: Vilnius, Lithuania

PostPosted: Sat Jul 24, 2021 11:25 pm
Reply with quote

This is a forum for experts, 'nuff said!
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2140
Location: USA

PostPosted: Sun Jul 25, 2021 2:13 am
Reply with quote

TGarcia wrote:
How can I add multiple variables from String?

You need mandatory attend training classes for beginners at your school.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 734
Location: Denmark

PostPosted: Sun Jul 25, 2021 3:10 pm
Reply with quote

I assume that by 'add' you mean 'concatenate', for that you use the concatenation operator || , which is described in the 'z/OS TSO/E REXX Reference' manual 'REXX General Concepts' section.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Sun Jul 25, 2021 5:46 pm
Reply with quote

NO, the TS wants to count the occurrences of each stem value
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2593
Location: Silicon Valley

PostPosted: Mon Jul 26, 2021 1:36 am
Reply with quote

Quote:
How can I add multiple variables from String?

Sorry, but your statement is unclear. Perhaps you can restate it.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Mon Jul 26, 2021 11:32 am
Reply with quote

there is certainly a language barrier
but the sample input and the expected output are clear enough to provide an answer
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 734
Location: Denmark

PostPosted: Mon Jul 26, 2021 1:35 pm
Reply with quote

Ah, I should have spent a few more minutes reading the question, it really is about counting,
That makes it much more interesting and relevant to this forum.
Here is my take on a solution:
Code:

 a.1 = 'red apples'                 
 a.2 = 'green apples'               
 a.3 = 'yellow bananas'             
 a.4 = 'red apples'                 
 a.5 = 'yellow bananas'             
 a.0 = 5                           
 count.=''                         
 cn    =0                           
 do n=1 to a.0                     
   v=a.n                           
   if count.v='' then do /* new */ 
     cn=cn+1                       
     count.v=1                     
     count.cn=v                     
   end                             
   else count.v=count.v+1           
 end                               
 do n=1 to cn                       
   v=count.n                       
   say "Count of '"v"'="count.v     
 end                               
Back to top
View user's profile Send private message
TGarcia

New User


Joined: 24 Jul 2021
Posts: 3
Location: United States

PostPosted: Thu Jul 29, 2021 8:40 pm
Reply with quote

Thank you Willy Jensen!!!!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Run rexx with JCL Job CLIST & REXX 3
No new posts Run rexx in batch job CLIST & REXX 7
No new posts Does anyone know rexx for VSE CLIST & REXX 3
No new posts TSO ALLOC In REXX Needs Improvement JCL & VSAM 3
No new posts REXX/CMS How to place command console... CLIST & REXX 4
Search our Forums:

Back to Top