| |
ashok_ganeshs
Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
|
Hi All, Simple script people who are workin in Biztalk (Hippa) based work. Usage : 270 and 820's Purpose : Replace the HL values Based on 20's ,21 and 22. For 270's * ******************************************************************************** ******************************************************************************** ******************************************************************************* ' Script Name:HLValue_270.vbs ' Written by: Your Name ' DATE : 01/10/2007 ' COMMENT: Change the HL 01 and HL02 value based on 20 and 21. '=========================================================== ' Constant values '=========================================================== Const ForReading = 1, ForWriting = 2, ForAppending = 8 'const existvalue = "Test" 'const replacevalue = "TEST" '=========================================================== '=========================================================== If WScript.Arguments.Count <> 2 Then WScript.Echo("USAGE: Please give the inputFile and outputFile Name") WScript.Quit End If ' Read input arguments Dim inMap, outMap inMap = WScript.Arguments(0) log("Input File = " + inMap) outMap = WScript.Arguments(1) log("Output File = " + outMap) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") Dim tsi, tso Set tsi = fso.OpenTextFile(inMap, ForReading) Set tso = fso.OpenTextFile(outMap, ForWriting, True) Dim HL(5) HL(1)="(^HL." HL(2)="*\" HL(3)="*\" HL(4)="*20\" HL(5)="*1)" Dim rgo1 : Set rgo1 = New RegExp With rgo1 '.Pattern = "HL(1)HL(2)HL(3)HL(4)HL(5)" .Pattern = "(^HL.*\*\*20\*1)" '.Pattern = "(^HL.*\*\*20\)" .Global = True End With Dim rgo2 : Set rgo2 = New RegExp With rgo2 .Pattern = "(^HL.*\*21\*1)" .Global= True End With Dim rgo3: Set rgo3= New RegExp With rgo3 .Pattern = "(^HL.*\*22\*0)" .Global = True End With '=========================================================== 'Start looping the file here '=========================================================== Dim tempStr, rgExp, Count,HL01,HL02 Count = 1 Do Until tsi.AtEndOfStream 'Read line from the input file tempStr = tsi.ReadLine rgExp = rgo1.Test(tempStr) If rgExp Then tempstr= tso.Write("HL*"& Count & "**20*1") 'tempStr = rgo1.Replace(tempStr, Count) 'HL*1*2*20*0 'tempStr = rgo1.writeline(HL(1),HL(2),HL(3),HL(4),HL(5)) 'HL*1*2*20*0 HL01=Count Count = count + 1 'HL02= Count End If rgExp = rgo2.Test(tempStr) If rgExp Then 'tso.WriteLine("TEST") 'HL01=1 tempstr= tso.Write("HL*"& Count &"*"& HL01& "*21*1") 'tempStr = rgo2.Replace(tempStr, Count) 'HL*2*1*21*0 HL02= Count Count = Count + 1 End If rgExp = rgo3.Test(tempStr) If rgExp Then 'tso.WriteLine("TEST") 'HL01=1 tempstr= tso.Write("HL*"& Count &"*"& HL02& "*22*0") 'tempStr = rgo2.Replace(tempStr, Count) 'HL*3*2*22*0 ' HL02= Count Count = Count + 1 End If 'Count= Count + 1 'Write line into the output file tso.WriteLine(tempStr) Loop Function log(Msg) WScript.Echo Msg End Function WScript.Quit * ******************************************************************************* * ******************************************************************************* * ******************************************************************************* For 820's '=========================================================== ' Script : Change the HL Values based on 820's ' Written by: Your Name '=========================================================== ' Constant values '=========================================================== Const ForReading = 1, ForWriting = 2, ForAppending = 8 'const existvalue = "Test" 'const replacevalue = "TEST" '=========================================================== '=========================================================== If WScript.Arguments.Count <> 2 Then WScript.Echo("USAGE: CScript Hextest.vbs inputFile outputFile") WScript.Quit End If ' Read input arguments Dim inMap, outMap inMap = WScript.Arguments(0) log("Input Map = " + inMap) outMap = WScript.Arguments(1) log("Output Map = " + outMap) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") Dim tsi, tso Set tsi = fso.OpenTextFile(inMap, ForReading) Set tso = fso.OpenTextFile(outMap, ForWriting, True) Dim HL(5) HL(1)="(^HL." HL(2)="*\" HL(3)="*\" HL(4)="*20\" HL(5)="*1)" Dim rgo1 : Set rgo1 = New RegExp With rgo1 '.Pattern = "HL(1)HL(2)HL(3)HL(4)HL(5)" .Pattern = "(^HL.*\*\*20\*1)" '.Pattern = "(^HL.*\*\*20\)" .Global = True End With Dim rgo2 : Set rgo2 = New RegExp With rgo2 .Pattern = "(^HL.*\*22\*0)" .Global = True End With '=========================================================== 'Start looping the file here '=========================================================== Dim tempStr, rgExp, Count,HL01 count = 1 do until tsi.AtEndOfStream 'Read line from the input file tempStr = tsi.ReadLine rgExp = rgo1.Test(tempStr) If rgExp Then tempstr= tso.Write("HL*"& Count & "**20*1") 'tempStr = rgo1.Replace(tempStr, Count) 'HL*1*2*20*0 'tempStr = rgo1.writeline(HL(1),HL(2),HL(3),HL(4),HL(5)) 'HL*1*2*20*0 HL01=Count Count = count + 1 End If rgExp = rgo2.Test(tempStr) If rgExp Then 'tso.WriteLine("TEST") 'HL01=1 tempstr= tso.Write("HL*"& Count &"*"& HL01& "*22*0") 'tempStr = rgo2.Replace(tempStr, Count) 'HL*2*1*22*0 'HL01=HL0+1 Count = Count + 1 End If 'Write line into the output file tso.WriteLine(tempStr) Loop Function log(Msg) WScript.Echo Msg End Function WScript.Quit ********************************************************************************* ********************************************************************************* *********************************************************************************
|
|