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: 1306
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: 2023
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: 712
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: 10873
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: 2547
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: 10873
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: 712
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 Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top