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
Warnings : 1

Senior Member


Joined: 07 Feb 2009
Posts: 1263
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
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1189

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 User


Joined: 01 Sep 2015
Posts: 495
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: 10801
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: 2258
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: 10801
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 User


Joined: 01 Sep 2015
Posts: 495
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 How to modify file content using REXX CLIST & REXX 3
No new posts Adding a header when change data DFSORT/ICETOOL 6
No new posts Same command as on commandline in REX... TSO/ISPF 6
No new posts process statement for SUPREC, CMPCOLM... TSO/ISPF 4
No new posts REXX SDSF filtering CLIST & REXX 8
Search our Forums:

Back to Top