comparing stem variables



IBM's Command List programming language & Restructured Extended Executor

comparing stem variables

Postby yodish » Sat Dec 15, 2012 3:09 am

I need to calculate total alarm real-time for multiple applications. Meaning there are times when different application's alarms may overlap each other. For instance,


start time stop time
Alarm A 04:10:16 17:04:58
Alarm B 15:59:33 17:01:08
Alarm C 17:00:28 17:00:38
Alarm A 04:10:16 15:52:32
Alarm C 11:26:45 11:40:56
Alarm C 04:10:16 11:18:04

Currently, I am parsing these into stem variables. I know the equation I need.
Compare first alarm stop time to second alarm start time, if it is Greater than/Equal then combine first and second alarm (using first alarm start time and second alarm stop time):
Alarm A 04:10:16 17:04:58
Alarm B 15:59:33 17:01:08 --> 04:10:16 17:01:08

repeat this process.

My question is, what is the best way to approach this? Can you use the COMPARE on two stem variables?

TIA
yodish
 
Posts: 23
Joined: Thu Oct 25, 2012 3:03 am
Has thanked: 0 time
Been thanked: 0 time

Re: comparing stem variables

Postby enrico-sorichetti » Sat Dec 15, 2012 3:26 am

Can you use the COMPARE on two stem variables?


??? what does that mean ???

a stem variable can be used as a <normal> variable

if stemone.i = stemtwo.j then  do
    ...
end
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: comparing stem variables

Postby Akatsukami » Sat Dec 15, 2012 3:29 am

Your terminology is a bit confused; A. is a stem, A.I is a compound symbol (or compound variable).

No, the COMPARE function cannot be used on stems, only on strings (which compound symbols resolve to). Having parsed the lines into stems, IMNSHO your best bet would be to compare them in a loop i = 1 to alarm.0 (remember that, although storing the nuber of assigned variables in stem.0 is a common convention, it is only a convention, and Rexx will not automatically do it for you). Do not forget to handle crossings of the midnight boundary.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: comparing stem variables

Postby yodish » Mon Dec 17, 2012 10:59 pm

in that case, is there a way to concatenate stem.1 and stem.2 into one string?

start time stop time
Alarm A 04:10:16 17:04:58 <-- stem.1
Alarm B 15:59:33 17:01:08 <-- stem.2 ---would equal --> Alarm A 04:10:16 17:04:58 Alarm B 15:59:33 17:01:08
Alarm C 17:00:28 17:00:38
Alarm A 04:10:16 15:52:32
Alarm C 11:26:45 11:40:56
Alarm C 04:10:16 11:18:04
yodish
 
Posts: 23
Joined: Thu Oct 25, 2012 3:03 am
Has thanked: 0 time
Been thanked: 0 time

Re: comparing stem variables

Postby Akatsukami » Mon Dec 17, 2012 11:35 pm

yodish wrote:in that case, is there a way to concatenate stem.1 and stem.2 into one string?

start time stop time
Alarm A 04:10:16 17:04:58 <-- stem.1
Alarm B 15:59:33 17:01:08 <-- stem.2 ---would equal --> Alarm A 04:10:16 17:04:58 Alarm B 15:59:33 17:01:08

Of course:
do i = 1 to alarm.0 by 2
  j = i + 1
  conjoin = alarm.i" "alarm.j
  /* Other processing */
end

/* Logic to handle possibility of odd number of alarms */
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: comparing stem variables

Postby yodish » Thu Dec 20, 2012 7:01 pm

Thanks Akatsukami, that got me on the right track!
yodish
 
Posts: 23
Joined: Thu Oct 25, 2012 3:03 am
Has thanked: 0 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post