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!

Beginner Question

Status
Not open for further replies.

HITAspect

Technical User
Apr 29, 2005
4
US
I just started with Aspect, I have a situation where I create a list, send that list to a device, capture the device, and then sort the data for a specific sequence. I have figured out everything but the sort. Here is an example of the proc/file:


proc main

string FName ; Name of file to read.
string LineInfo ; Line from file.
string CName = "file.cap"

set capture file CName
clear
capture on
if sdlginput "File Name" "Name:" FName
if isfile FName ; Make sure file exists.
if fopen 0 FName READ ; Open file for read.
while not feof 0 ; Loop to end of file.
fgets 0 LineInfo ; Get line from file.
transmit "RTRV-T1::"
transmit LineInfo
transmit ":BW;^M"
endwhile
fclose 0 ; Close the file.
endif
else
errormsg "File doesn't exist."
endif
endif
pause 10 ;pause for terminal completion
capture off ;end capture

endproc


file.cap --

RTRV-T1::0840-14:BW;

5500 05-04-30 00:38:34
M BW COMPLD
"0840-14:DGR:pMAID=PM1D-0839-13,TACC=0,IDLECDE=AIS,OOSCDE=AIS,LINECDE=B8ZS,FMT=ESF,EQLZ=1,GOS=99,ALM=INH,ALMPF=99,FENDPMTYPE=ANSI
403,DS1ADDR=C,CSUADDR=B,TMG=THRU,FLTRC=NONE,PASUSP=OFF,SSM=NA,SSMDS1MODE=OFF,SSMUSER=SYS,PARTNAME=UASPART:pST=IS-NR"
;


--------------------------
What I need to know is how do delete the RTRV line and the blank lines? Everything within the " " is a record. I need to query if the 840-14 record has LINECDE=B8ZS, if not, I need it to flag that record? Any ideas - knob?
 
Do you need to edit the capture file so that it has the format you need? If so, I would open a second text file and output lines (using fputs) to that file, once you have determined if they are lines you want. For example, you can use the strfind command to check for lines with RTRV and simply not output that line to the filtered file. To check for blank lines, you can use the strlen command on the line you just read, and if it is zero, it is blank and can be discarded. Keep in mind that what looks blank to you may have spaces, tabs, etc. so you might need to look for those also.

For the last task, you can use strfind there as well to determine if the particular setting is present or not.

 
I have made some progress but I am stumped, I am still trying to figure out how to only output the information that is within the quotes. I was able to start to output based on the " but am uncertain how to output every character on the same line until it sees the second quote, then insert a new line and loop. Thanks in advance for the help.

proc main
string FName ; Name of file to read.
string FName2 ; Name of file to create.
;string CName
string LineInfo
string LineInfo2

clear
;sdlginput "Capture Name" "Name:" CName
;set capture file CName
;capture on
if sdlginput "File Name" "Name:" FName
sdlginput "Output File Name" "Name:" FName2
if isfile FName ; Make sure file exists.
if fopen 0 Fname READ ; Open input file for read.
if fopen 1 FName2 CREATE TEXT ; Create output file.
while not feof 0 ; Loop while not at end of file.
fread 0 LineInfo 2
if strchr LineInfo '"' ; Check for target text in string.
while not feof 0
fread 0 LineInfo2 2
if LineInfo2'"'

else
fputs 1 LineInfo2
endif
endwhile
usermsg "value `"%s`" " LineInfo
else
usermsg "Target string not found in search string!"
endif
endwhile
fclose 1 ; Close our output file.
else
errormsg "Couldn't open `"%s`" for output." FName2
endif
fclose 0 ; Close the file.
endif
else
errormsg "File doesn't exist."
endif
endif
pause 9 ;pause for terminal completion





;capture off ;end capture

endproc
 
If you only expect two double quotes in the string you are processing, then you could use strrchr to get the position of the rightmost double quote, then use a command such as substr to extract the string data between the double quotes.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top