Page 1 of 1

comparing stem variables

PostPosted: Sat Dec 15, 2012 3:09 am
by yodish
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

Re: comparing stem variables

PostPosted: Sat Dec 15, 2012 3:26 am
by enrico-sorichetti
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

Re: comparing stem variables

PostPosted: Sat Dec 15, 2012 3:29 am
by Akatsukami
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.

Re: comparing stem variables

PostPosted: Mon Dec 17, 2012 10:59 pm
by yodish
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

Re: comparing stem variables

PostPosted: Mon Dec 17, 2012 11:35 pm
by Akatsukami
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 */

Re: comparing stem variables

PostPosted: Thu Dec 20, 2012 7:01 pm
by yodish
Thanks Akatsukami, that got me on the right track!