Link to home
Start Free TrialLog in
Avatar of hoshie329
hoshie329Flag for Afghanistan

asked on

VB Script needed

Hello,

I am needing a script to open a file, search for two different things in the text, then write to the file based on what it finds.  The file that needs to be opened is located in the "c:\tpnt\tester\" directory and the file name is "TP600.cur".  It needs to search first for "iisnaic.com" and if it finds that anywhere in the file quit.  If it does not find that it needs to search for "DEST#*" the * will be a single digit 0-9 and it will need to return what the highest digit is and then write the following;

DEST#*="IBT FBI" EMLDMN trace.xfm trace.xfm SMTP 1
DEST#*:REXX=
EML_DEST#*.CONTENTTYPE=Content-type: application/octet-stream ; name=efts.sub
EML_DEST#*.FROM:0=arlington@IBT.com
EML_DEST#*.MULTIPART=FALSE
EML_DEST#*.SERVER:0=iisnaic.com
EML_DEST#*.SUBJECT:0=%ORI(0)% + "." + %TCN(0)% + ".APPLICANT"
EML_DEST#*.TO:0=livescan@iisnaic.com

All of the * will need to be replaced with the next sequential number from above.  So if the highest it returns is DEST#3 I need it to write each * as a 4.  

Any help with this would be greatly appreciated.
Avatar of Bill Prew
Bill Prew

Please provide a sample input file, and the result output file you would want.

~bp
Avatar of hoshie329

ASKER

The file name for both will be the same TP600.cur.  This will be run on multiple machines with different configs.  The compareable fields will be the DEST# fields.  I have attached a sample TP600.cur file.  The file will be quite a bit longer than this, I had to remove quite a bit that was confidential.
tp600.cur.txt
So in a given input file, all the DEST#* values will be the same?  So in the case of the file you provided they are all DEST#0.  Once we see one that has a vlaue, do we have to look at every other one, or are they all the same?

Is it safe to assume that all places where DEST#0 occur in the file, they get replaced by DEST#1?

~bp
Not Necessarily, some of the machines have multiple destinations.  All that we really need it to find is what the last sequential one is since we do not want to modify anything that is already set up.  So if we are able to set it up to search for DEST#0 and if it finds it anywhere go on to search for DEST#1 and so on until it does not find the DEST#* that we are looking for that would work.  They will always be in sequential order so if there is a DEST#2 there has to be a DEST#1 and DEST#0.  For our software to recognize it as being valid the one we are adding has to be the next one in sequential order.
What's the highest DEST#* that can exist in the file?

Once we find the "next" number to use, what are we doing to the file?  Origianlly I read it as we are changing ALL the DEST#* in the file to DEST#n, where n is the next available number.  But if there are multiple numbers already in the file I wouldn't think you'd be changing them all to the same number.  Or are we adding new lines to the end of the file, leaving the rest as is?  Not clear on what you want to output to be.

~bp
The highest number would be 8 which would make our highest number to be used 9.  

Once we find the next number we are going to write the following lines at the end of the file.  

DEST#*="IBT FBI" EMLDMN trace.xfm trace.xfm SMTP 1
DEST#*:REXX=
EML_DEST#*.CONTENTTYPE=Content-type: application/octet-stream ; name=efts.sub
EML_DEST#*.FROM:0=arlington@IBT.com
EML_DEST#*.MULTIPART=FALSE
EML_DEST#*.SERVER:0=iisnaic.com
EML_DEST#*.SUBJECT:0=%ORI(0)% + "." + %TCN(0)% + ".APPLICANT"
EML_DEST#*.TO:0=livescan@iisnaic.com

For all of the * is where we will put the next number in the sequence.  Yes we will be leaving the rest of the file as it was before.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
All tests are going great with this.  Thank you!
Welcome, thanks for the feedback.

~bp