Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking For A Blank Character

Status
Not open for further replies.

TMurdach

IS-IT--Management
Apr 18, 2003
61
US
Below is a piece of script used to capture rows of a terminal session.

I'm looking for a way to have the code listed below check the 2nd character of each row to make sure it is NOT blank - if it is a blank character I do not want that row captured into the TXT file... I would like to skip the entire row and move to the next.

One other enhancement I'm trying to make during the screen capture process is replace any instance of the | (pipe) character with a comma so it opens up neatly in Excel. The pipe character is used to separate data elements.

Thank you!

Code:
proc page1
   string Line              ; Line to write to file.
   integer Row              ; Current row to get.
pause 3

   
      if fopen 1 "C:\SUMMARY.csv" APPEND
      for Row = 0 upto 20    ; Loop through each row
      termgets Row 0 Line 79  ; Get line specified by row.
      fputs 1 Line            ; Write line
      fputs 1 "`r"
      endfor
      fclose 1                   ; Close file opened for create.
   else

      errormsg "Couldn't open file!"
   endif

endproc
 
I found the character replacement function...

strreplace Line "|" ","
strreplace Line "+" ","

I think I have found a way to determine if the 2nd character is blank using strtok... I'll update the thread if I do.
 
Probably the easiest way to do this is to use the strget command to pull the ASCII value of the second character in the line and compare it to the possible values that may be sent (space, tab, etc.).


 
I think I've been working on this too long!

I'm dialed into an Executone Custom Plus reporting system and I can capture page after page of the agent stats. First I capture the header, then I use the "while" command to repeat capturing the agent stats page by page [down arrow flips to the next page]. My problem is I can't figure out how to escape the loop when there are no more agents to list. Based on agent schedules, you never know how many will work, so I can't simply repeat the agent stats capture 5 times, then capture the footer and disconnect. I could do that, but the reports would show the same data repeated since the down arrow doesn't work if there are no more agents.

I can paste the code I have but I figured somebody might have a template I can chop up - my code is embarrasing.

So to summarize my situation:

1. Capture the header - row by row
2. Capture the agent stats - row by row, using down arrow to get to the next page
3. Monitor the rows of data as they are being read to the variable for a pattern indicating there are no more agents
4. When the NO MORE AGENT STATS condition is met, capture the footer [totals] and end the script

Here is how I capture the terminal screen:

Code:
     if fopen 1 "C:\REPORTS\AGENT_SUMMARY.csv" APPEND
      for Row1 = 0 upto 7 ; this is the header
         termgets Row1 0 Line1 79
         strreplace Line1 "|" ","
         strreplace Line1 "+" ","
         fputs 1 Line1
         fputs 1 "`r"
      endfor
      fclose 1
   else
      errormsg "Couldn't open file!"
   endif
   
     if fopen 1 "C:\REPORTS\AGENT_SUMMARY.csv" APPEND
      for Row2 = 8 upto 19 ;these are the rows of agent stats
         termgets Row2 0 Line2 79
         strreplace Line2 "|" "," ;replacing the pipe with comma for excel
         strreplace Line2 "+" "," ;replacing the + with comma for excel
         fputs 1 Line2
         fputs 1 "`r"

      endfor

      fclose 1
   else
      errormsg "Couldn't open file!"
   endif
This screen of stats is full, there are no blank lines of agent stats, meaning I need to page down after capturing for another page

Code:
                      (E1) Historical Agent Time Activity

 Period Covered  Thu Mar 17 00:00:00 2005   Through  Thu Mar 17 23:59:59 2005

                       HH:MM  HH:MM  HH:MM  HH:MM  HH:MM  MM:SS  MM:SS  MM:SS
 Agt|  Agent   |Calls |Total |Total |Total |Total | Not  | Avg. | Avg. | Avg.
 Num|  Name    |Ansrd |Login |BsyACD|WrapUp|Avail |Avail |BsyACD|WrapUp|Ring
 ­­­+­­­­­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­
 017|C-GREY    |    66|  6:41|  4:15|  0:01|  1:44|  0:16|  3:52|  0:01|
 018|C-FARREL  |   116|  7:32|  4:43|  0:02|  1:29|  0:37|  2:26|  0:01|
 019|C-LUISE   |    11|  0:40|  0:24|      |  0:12|  0:01|  2:14|  0:01|
 020|C-ZORIO   |    45|  3:59|  2:20|  0:01|  0:53|  0:30|  3:07|  0:01|
 023|C-DORNEY  |    46|  3:26|  1:53|  0:01|  0:50|  0:09|  2:28|  0:01|
 026|C-MCMAHON |   114|  7:19|  3:54|  0:02|  1:23|  0:29|  2:03|  0:01|  0:01
 027|C-MACRI   |    89|  6:27|  4:32|  0:02|  0:53|  0:21|  3:03|  0:01|
 028|C-BERRY   |   106|  7:53|  4:47|  0:02|  1:14|  0:39|  2:42|  0:01|
 029|C-KIDWELL |   126|  7:31|  4:53|  0:02|  1:18|  0:24|  2:19|  0:01|
 031|C-LEONARD |   110|  7:40|  4:32|  0:01|  1:11|  0:11|  2:28|      |
 032|C-HAYES   |    37|  1:52|  1:18|      |  0:02|      |  2:06|  0:01|
 033|C-GRAVES  |    81|  6:30|  2:43|  0:01|  0:37|  0:58|  2:01|  0:01|

 Totals -         3830|250:17|152:47|  1:31| 49:23| 11:53|  2:23|  0:01|
                      |      |      |      |      |      |      |      |
      F1-Exit      F2-Change a date/agent range      F3-Print      ?-Help
This screen of stats is NOT full, there are blank lines of agent stats towards the bottom, meaning I need to capture the agent stats on this page, as well as the footer and end the script.
Code:
                      (E1) Historical Agent Time Activity

 Period Covered  Thu Mar 17 00:00:00 2005   Through  Thu Mar 17 23:59:59 2005

                       HH:MM  HH:MM  HH:MM  HH:MM  HH:MM  MM:SS  MM:SS  MM:SS
 Agt|  Agent   |Calls |Total |Total |Total |Total | Not  | Avg. | Avg. | Avg.
 Num|  Name    |Ansrd |Login |BsyACD|WrapUp|Avail |Avail |BsyACD|WrapUp|Ring
 ­­­+­­­­­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­+­­­­­­
 046|C-JACKS   |    97|  6:24|  3:27|  0:01|  0:49|  0:22|  2:08|  0:01|
 047|C-RAMSEY  |    87|  4:40|  2:37|  0:02|  1:43|  0:10|  1:48|  0:01|
 048|C-RANDAZZ |    94|  6:07|  4:02|      |  0:56|  0:17|  2:34|      |
 049|C-JANSSEN |   127|  6:24|  4:42|  0:03|  1:09|  0:04|  2:13|  0:01|
 051|C-PLACELL |    58|  3:34|  3:10|  0:01|  0:13|  0:07|  3:16|  0:01|
 052|C-O'KEEFE |    30|  4:56|  1:46|  0:01|  0:38|  0:14|  3:32|  0:03|
 055|C-RIOS    |    85|  6:54|  5:27|  0:03|  0:39|  0:09|  3:51|  0:02|
 059|C-ARCHIE  |    88|  6:54|  3:59|  0:02|  2:08|      |  2:43|  0:01|
 060|C-GOLDEN  |   112|  5:28|  4:04|  0:07|  0:57|  0:05|  2:11|  0:04|
 061|C-SOLOMO  |    99|  4:41|  3:14|  0:07|  0:49|  0:12|  1:57|  0:04|
    |          |      |      |      |      |      |      |      |      |
    |          |      |      |      |      |      |      |      |      |

 Totals -         3830|250:17|152:47|  1:31| 49:23| 11:53|  2:23|  0:01|
                      |      |      |      |      |      |      |      |
      F1-Exit      F2-Change a date/agent range      F3-Print      ?-Help
 
Thanks for the tip knob. I couldn't figure out how to get it to work using exitfor, but I did figure out a way using rstrcmp. I've got the basic concept working, so now I just have to make a couple tweaks.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top