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!

Aspect and capture file finesse Help

Status
Not open for further replies.

ImaThib

Technical User
Jun 6, 2005
7
US
Help!
I am trying to write a script that will distinguish a character set that appears twice in my data I am capturing.
The data is a direct feed from an instrument using zmodem. The capture file simply looks for a character string and then captures until the process finishes. My script opens perfectly as I complete the beginning string.
My problem is the difference between the beginning and ending of this file is similar. The order of the characters is different with a carriage return. I need a command that will ignore the first instance and stop at the second instance.
Any help is appreciated.
[sadeyes]

 
Probably the best way is to use a when target command in conjunction with an global integer variable acting as a flag. Initialize the integer to zero, then check the value in the procedure called by the when target command. If zero, then set the integer value to one and exit. If the value is one, then you know this is the second time the string has arrived and can close the capture file.


 
Knob,

Thank you. I'll try it. Next question. This machine has the ability to start a number of stored tests. Is there a way to use this to also start another capture file to start when this happens?
It would be a definable point to catch but would need to be in a separate file.

I appreciate the wisdom,

Thib
 
Do you mean that the machine you are connecting to can basically spit out a pre-defined set of strings and you would need to identify when one of those strings (or tests) occurs and open a new capture file? If so, the one sticking point is that the data has to be seen for Procomm to capture. What you can usually do is clear the screen before you start a capture file so you don't get "old" data in a new capture file. However, in your case, you would be clearing part of the beginning of the test to capture, so your final capture file would not be complete. Does it matter if the end data from a previous test is in the capture file? Or does the system only send one of these tests when you instruct it to?


 
knob,
Good questions.
My machine is an older lab instrument that in simple terms uses procomm to setup the tests. If more than one test is setup the data setup string is started right after the 1st setup information.
It then starts the test with the string I need to avoid. After it completes, it transmits the string I want to use to turn off the capture to generate a file. I then want to open a new file if there is another test waiting. After the end of the first the test name abbreviated is sent to procomm and the test starts.

Here is the script, so far.


proc main

string sCapPath, sCapFile, sCapFile2, sNewFile
integer iDay, iMonth, iYear, iHour, iMin, iSec
set modem connection "direct connect-Com1"
set port baudrate 1200
set port parity mark
set port databits 7
set port stopbits 1
set capture path "v:\StatLIA32\micromedic2241"
set capture file "temp"

fetch capture path sCapPath

while 1
clear
waitfor "INPUT (A=ASSAY; S=STAT; B=BKGND; V=VERIFY): A" forever
capture on

when TARGET 0 "^M " call capoff

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt sNewFile "%s%d%02d%02d%s%02d%02d" iYear iMonth iDay "_" iHour iMin
strcat sNewfile ".TXT"
strfmt sCapFile "%s\temp.txt" sCapPath
strfmt sCapFile2 "%s\%s" sCapPath sNewFile
shortpath sCapFile sCapFile
rename sCapFile sCapFile2
; usermsg sNewfile
endwhile
endproc

proc capoff
capture off
endproc

What am I missing, oh wise one?
 
Is this the line that appears before each test?

INPUT (A=ASSAY; S=STAT; B=BKGND; V=VERIFY): A

And does the string in the when target command always signify the end of each test?


 
Yes to both.
INPUT (A=ASSAY; S=STAT; B=BKGND; V=VERIFY):
is the line the machine presents for the option to choose. When I enter the "A" the capture command starts.
The string appears at the the start and at the end.
 
It looks to me like the script you posted should be able to handle multiple tests. What kind of problems are you running into?

One small change I would make is moving the when target command outside of the while loop since I have seen a couple cases where continually redefining a when command causes "weird stuff" but I doubt it applies in this particular case.


 
OK.
What defines the end of the while loop command?

The file capture off never fires. I still have the capture on and manually turn it off.


On the other note, between tests this is the information
 
INPUT (A=ASSAY; S=STAT; B=BKGND; V=VERIFY):  

on 3 lines.

Thib
 
Are you sure that the string in the when target command is correct? If it is even one charater off, the capoff procedure will not be called. One example of this would be embedded control characters or escape sequences. To verify the string, you can use the Monitor Window in Procomm. Here is some information I have copied from my site:

Procomm's Monitor Window can be used to view the incoming and outgoing data, in both hex and ASCII format. To activate this window, select the Data | Monitor Window menu item. Resize the Monitor Window so that you can view the entire width of the window, then click back in the Procomm Plus window so that the Monitor Window does not have focus. Incoming text is displayed in red, while text you send is colored blue. The Monitor Window can be handy for viewing incoming escape sequences (to determine if Procomm Plus is responding properly to them) or to verify that the program is sending the data you think it should be.

I would also move the code to rename the capture file to the capoff procedure.


 
I used the monitor capture. I did actually see alot more spaces than I had entered.

I'm trying the new string line for a trial run.
My next problem is that the multiple files that may be loaded and will run in sequence are definable in a similar manner.
The statement above to start the capture file is entered only at the beginning. Between runs the next test run is defined as 72 of these (). The start of each new test is defined as 68 of these ().

What would I need to do to write the argument to look for this?

If I wanted to capture a typed message in the comment field to use as the new name of the saved file, how would I do that?

As you can see, my programming skills are very rusty.

Thanks for any help,
Thib
 
Is the typed message entered by the user, or is it something that comes across in each test? If the former, you can use the sdlgsaveas dialog to prompt the user for a name for the new file. If the latter, then you would want to use a waitfor or when target command to watch for that data, then most likely use something like termgets $ROW 0 to read that line from the screen, then do the necessary parsing to get the test name.

I think the easiest way to handle the additional downloads, assuming I have it understood correctly, is to add a when clear command to the capoff procedure, then add a new when target command for the slightly different string. However, I'm not quite certain I followed the exact sequences of tests and cases, so that may not work as I had hoped.


 
The typed statement in the Comment field is entered by the analyst. I would like for the file to default to the study number entered in the comment field. Might be to complicated, but I'd like to try. "COMMENT: " is added by the instrument.

When I set up the test, I get a question asking if I want to setup another. I answer yes and I go through all the same prompts. I have the ability to setup 6 in advance. It would be great to be able to refer back to the setup interaction for each test and have that saved to its respective file, but I would settle for being able to capture that data in its own file if more than one test is being run.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top