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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pull data from screen from a Meridian 1 1

Status
Not open for further replies.

PackRat1

Technical User
Mar 22, 2006
50
US
I am trying to do an IDCS via a script. I would like to pull the information from LD 97 and use that information to query the controllers. The following script would return a list of controllers

1st part of script

Code:
PROC MAIN

integer [b]idcscnt[/b]=1
integer [b]xpecmax[/b]=0

transmit "****^M"
transmit "LD 97"
waitfor "REQ"
transmit "PRT^M"
waitfor "TYPE"
transmit "XPE^M"
waitfor "XPEC"
transmit "^M"

S0 S1 S2 S3 LOC DIS RGTP

01 008 008 008 008 NO 08
02 020 020 020 020 NO 08
03 004 004 004 004 NO 08
04 004 004 004 004 NO 08
05 008 008 008 008 NO 08
06 020 020 020 020 NO 08
07 028 028 028 028 NO 08
08 036 036 036 036 NO 08

I would like to store 8 (last controller) to the variable xpecmax. Then

Code:
while idcscnt <= xpecmax
transmit "IDCS "
transmit idcscnt ^M
WAITFOR "."
idcscnt++
ENDWHILE

ENDPROC

Anybody have any Idea if this can be done and how?
 
What you're wanting to do should be fairly simple.

The method that I prefer to get information from the screen is to capture it to a file, then read it back in. There are other way's, but this is the simplist that I've found (in my opinion.)

Code:
PROC MAIN

string sTemp
integer idcscnt=1
integer xpecmax=0

delfile "c:\temp.txt"
set capture path "C:\"
set capture file "temp.txt"

set capture on
transmit "****^M"
transmit "LD 97"
waitfor "REQ"
transmit "PRT^M"
waitfor "TYPE"
transmit "XPE^M"
waitfor "XPEC"
transmit "^M"
set capture off

if fopen 0 "c:\temp.txt" READ TEXT
     for index = 1 upto 3  ' adjust this, based on # of junk lines before your data (at the top of the file.)
          fgets 0 sTemp
     endfor
     
     while not eof 0
          if strnicmp sTemp "08" 2
                xpecmax = sTemp
          else
               fgets 0
          endif
     endwhile
else
     usermsg "Can't open file!"
endif

.....
 
while not eof 0
if strnicmp sTemp "08" 2
xpecmax = sTemp
else
fgets 0
endif
endwhile

I understand most except how it grabs the bottom record. The "08" in this case could be anywhere from 1 to 30 on the next system. Also I need to use the variable in the next part of the script.

Code:
[transmit "IDCS 1^M" ;this is where I would put the variable.
   waitfor "."
   transmit "IDCS 2^M"
   waitfor "."
   transmit "IDCS 3^M"
   waitfor "."
   transmit "IDCS 4^M"
   waitfor "."
   transmit "IDCS 5^M"
   waitfor "."
   transmit "IDCS 6^M"
   waitfor "."
   transmit "IDCS 7^M"
   waitfor "."
   transmit "IDCS 8^M"
   waitfor "."
I know I can set this up in an incrementing loop once I store the highest number into a variable.
 
Sorry, my mistake, I mis-read your post.

Code:
PROC MAIN

string sTemp, sTemp2
integer iStrLen
integer idcscnt=1
integer xpecmax=0

delfile "c:\temp.txt"
set capture path "C:\"
set capture file "temp.txt"

set capture on
transmit "****^M"
transmit "LD 97"
waitfor "REQ"
transmit "PRT^M"
waitfor "TYPE"
transmit "XPE^M"
waitfor "XPEC"
transmit "^M"
waitquiet 5 ' waits till data stops coming across (5 seconds)
set capture off

if fopen 0 "c:\temp.txt" READ TEXT
     for index = 1 upto 3  ' adjust this, based on # of junk lines before your data (at the top of the file.)
          fgets 0 sTemp
     endfor
     
     while not eof 0
          fgets 0 sTemp
          strlen sTemp iStrLen
          if iStrLen > 2
               sTemp2 = sTemp  '  parse the max value from sTemp2
          endif
     endwhile  'loops until last line of text
else
     usermsg "Can't open file!"
endif

.....

This way, if there's garbage at the bottom of the file, it'll only grab lines longer then 2 chars and assign to sTemp2. You can then parse out your max from this string.

Code:
' to parse out xpecmax from sTemp2
strrev sTemp2
strright sTemp sTemp2
strrev sTemp
strtonum sTemp xpecmax

....
' to tranmsit your values...

sTemp = "IDCS "
for index = 1 upto xpecmax
     strfmt sTemp2 "%s %d^m" sTemp xpecmax
     transmit sTemp2
     waitfor "." forever
endfor

....
 
Made a few tweeks but works like a champ. Thanks Again!

Code:
PROC MAIN

string sTemp, sTemp2
integer iStrLen
integer idcscnt=1
integer xpecmax
integer iXpec

delfile "c:\temp.txt"

set capture path "C:\"
set capture file "temp.txt"



transmit "****^M"
transmit "LD 97^M"
waitfor "REQ"
transmit "PRT^M"
waitfor "TYPE"
transmit "XPE^M"
waitfor "XPEC"
transmit "^M"

capture on

waitquiet 3 ; waits till data stops coming across

capture off

if fopen 0 "c:\temp.txt" READ TEXT
    ; for index = 1 upto 3  ;adjust this based on number of junk lines before your data (at the top of the file.)
    ;      fgets 0 sTemp
    ; endfor
     
     while not feof 0
          fgets 0 sTemp ;STORES LINE FROM FILE INTO STEMP
          strlen sTemp iStrLen ;COUNTS THE NUMBER OF CHAR IN LINE AND STORES IT TO ISTRLEN
          if iStrLen > 2
               sTemp2 = sTemp  ;  stores the string to sTemp2
              
		strrev sTemp2
		strright sTemp sTemp2 3
		strrev sTemp
		strtonum sTemp iXpec
		if iXpec <50
			xpecmax=iXpec
		else
			goto RUNIDCS
		endif
               
          endif
     endwhile  ;loops until last line of text
else
     usermsg "Can't open file!"
endif

; to tranmsit your values

RUNIDCS:

iXpec = 1
sTemp = "IDCS "


transmit "****^M"
waitfor ">" FOREVER
transmit "ld 32^M"
waitfor "."

while iXpec <= xpecmax
     strfmt sTemp2 "%s%d^M" sTemp iXpec
     transmit sTemp2
     waitfor "." forever
     iXpec++
endwhile

endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top