extracting from a stem variable



IBM's Command List programming language & Restructured Extended Executor

extracting from a stem variable

Postby yodish » Thu Oct 25, 2012 3:46 am

Hello,

I am reading a report in as a STEM variable and need to pull out the date, time and the alarm name. The alarm name is on the line below it's corresponding date and time, and therefore a different record, which is making my solution a little trickier.

I've been able to get the 3 variables organized together with this:

"EXECIO * DISKR indd 1501 (FINIS STEM LogRec."                         
Do i=1 to LogRec.0                           
parse var LogRec.i . '/' date . ,             
                 . 12 time 20 . ,             
                 . 21 alarmname 50 .   
/* allinfo = date time alarmname */               
/*IF SUBSTR(alarmname,10,5) = "$ABC9" THEN   
  do */                                       
 say date                             
 say time                                     
 say alarmname 
/* say allinfo                                   
 end   */                                       
end   


When I run the program like this (with seperate SAY statements), I get nice little packages in my output. I don't want most of them, but the ones I want look like this:
:Process $ABC9 is not running
09/25
12:00:33
¦ Alarm stopped ¦


:Process $ABC9 is now running
09/25
12:47:02
¦ First alarm ¦

The problem is (you can see the IF statement i've commented out), is that I only want the date, time and alarmsname when a certain alarm name (in this case $ABC9) appears within the alarmname string.

How can I associate the date and time variables that directly proceeded each of the alarm names?

If I uncomment the allinfo variable which concatenates the three variables, I still only get the alarmname strings; this is the closest i've come to the output I want though. I'd just like to see the date and time before each of these:
:Process $ABC9 is not running
:Process $ABC9 is now running
:Process $ABC9 is not running
:Process $ABC9 is now running
***

Here's a snippet of the report i'm reading in:

2012/09/25 11:49:22 ¦ First alarm ¦ ¦ RED ¦ ABC9 ¦ 2012/09/25 11:49:22
\Process $ABC9 is not running
2012/09/25 12:00:33 ¦ Alarm stopped ¦ ¦ INFO ¦ ABC9 ¦ 2012/09/25 11:49:22
\Process $ABC9 is now running


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

Re: extracting from a stem variable

Postby Pandora-Box » Thu Oct 25, 2012 10:23 am

I read your post multiple times I found it hard to understand what actually is needed

I would suggest you to state your with more clarity

Something like

Your input with code tags
Expected output with code tags
User avatar
Pandora-Box
 
Posts: 65
Joined: Fri Feb 10, 2012 8:30 pm
Location: Mars
Has thanked: 3 times
Been thanked: 6 times

Re: extracting from a stem variable

Postby mongan » Thu Oct 25, 2012 12:54 pm

You do need to post an example of your input. I would normally have two different statements, one for the date and one for the time, assuming you always have two records per incident. After the time you then can check all of your fields and react accordingly.
User avatar
mongan
 
Posts: 211
Joined: Tue Jan 11, 2011 8:32 pm
Has thanked: 1 time
Been thanked: 5 times

Re: extracting from a stem variable

Postby yodish » Thu Oct 25, 2012 5:34 pm

Thank you for your responses. I'm sorry my explanation wasn't that clear.

That is one of the problems, there aren't always 2 records per incident...sometimes there are 3, however it appears the incidents that I want to extract should always have 2 records. You have given me some different ideas to consider though, thanks.
yodish
 
Posts: 23
Joined: Thu Oct 25, 2012 3:03 am
Has thanked: 0 time
Been thanked: 0 time

Re: extracting from a stem variable

Postby yodish » Thu Oct 25, 2012 6:31 pm

I switched the IF THEN ITERATE ELSE to IF THEN ELSE ITERATE ...and it worked, sometimes you just need some feedback to get the mind thinking another way...thanks again
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