----------------------------- A ----------------------------------------- I did a code walk thru...some of the things rised in my mind
Function getDTmpl() Dim sRVal : sRVal = _ "File @Folder@\@File@:~Some*EDI*Data~TRN*2*BR0@File@@Folder@_FACILITY_Numeric*9526002033~Some*EDI*Data~" getDTmpl = sRVal End Function
am not understand this function look like values are hard code...correct me if am wrong.
----------------------------- E ----------------------------------------- Hey - are you a compiler that just ignores comments? ' ############################################################################ ''# getDTmpl - fake EDI test file content ''# todo: better EDI format; get a public sample and insert the ''# link part ' ############################################################################
----------------------------- A ----------------------------------------- if you have a close look at the file what i sent to you have TWO TRN'S basically i need to find the first TRN value or in the other words the TRN have vlaue "2" in between first and second star.
Then we pick that TRN and get the value between third and fourth stars.
----------------------------- E ----------------------------------------- That's valuable information. Looks like we have to modify
oRE.Pattern = "~TRN\*([^*]+)\*([^*]+)\*([^~]+)~"
in Function cutLink():
oRE.Pattern = "~TRN\*2\*([^*]+)\*([^~]+)~"
Now we look for records starting with "TRN*2*" to get the respective Link. Do you can comment on the last field? Must it be the same in a second file for that to be considered a candidate for detailed comparison?
And to remind myself: oRE.Pattern = "^TRN\*2\*([^*]+)\*([^~]+)$" if we work on a 'lined' file.
----------------------------- A ----------------------------------------- Obsolutely your other concept is right replace the ~ value with new line and make the file (i just upload that file to you)like your sample (your sample have this " |" and my file have "*") and do the compare should easy i think.
----------------------------- E ----------------------------------------- I used the sample to keep the secrets of your Admins secret. Thanks for the file; I'll check for the nasty control chars. Apropos 'easy' - looking at your code to compare to files, I seriously doubt that. You are aware of the fact, that your code compares numbers not lines?
----------------------------- A ----------------------------------------- i just copied the whole code and ran i got this result
****************************************************************** Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
ok, doTheRealWork() was called, but we aren't done yet! Exit code: 0 , 0000h
----------------------------- E ----------------------------------------- This is important information too. We could have spend a long time chasing bugs due to different versions. It would have been better to include the calling command line in the 'log'. One question: Where does "Exit code: 0 , 0000h" come from?
----------------------------- A ----------------------------------------- here i copied the code what i ran....advise me what am missing [...]
----------------------------- E ----------------------------------------- If you post code, use code blocks (ok, short portions enhanced with colors etc. are alright). Don't post more code than necessary. If you did change something, tell about it and post the changes.
As to what you are missing - I don't know. What other output/action did you expect from this code/comment.
' ############################################################################ ''# doTheRealWork - not known yet ' ############################################################################
Function doTheRealWork() Dim nRVal : nRVal = 0 ' assume ok WScript.Echo "ok, doTheRealWork() was called, but we aren't done yet!" doTheRealWork = nRVal End Function
Perhaps you missed my detailed log of my test runs that I posted after the script?
I will edit EdiComp.vbs to reflect the new information about the Link. That will make the purpose of the function getDTmpl() clearer. Give me some time (it's Friday evening in Germany) and spend some of it processing the comments too.
----------------------------- E ----------------------------------------- Hey - are you a compiler that just ignores comments? ' ############################################################################ ''# getDTmpl - fake EDI test file content ''# todo: better EDI format; get a public sample and insert the ''# link part ' ############################################################################ i was reading your comment after that i got this query raised in my mind...i was missed the other part what you poster here.
Here i changed the folder path (higlighted in Red),apart from that i didn't make any change in that code and run as it is.
FolderA and B i have only one file and both are same but still am not getting any output.
' ############################################################################ ''# global vars ' [ will grow as we proceed ] ' ############################################################################
Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" ) Dim gsFolderA : gsFolderA = "C:\FolderA" Dim gsFolderB : gsFolderB = "C:\FolderB"
(1) create a new directory "EdiComp" wherever you like (2) create two sub folders "EdiComp\FolderA" and "EdiComp\FolderB" (3) save my "EdiComp.vbs" (exactly as posted it) to "EdiComp\EdiComp-01.vbs" (4) open a dos box, cd to "<wherever>\EdiComp" (5) Create test data by running "cscript EdiComp createTD" (6) check if output looks like:
(7) Post "success" or "failure", including output in case of bad case.
is this some one will help me what i suppose to change the code higlighted in RED
' ############################################################################ ''# getDTmpl - fake EDI test file content ''# todo: better EDI format; get a public sample and insert the ''# link part ' ############################################################################
Function getDTmpl() Dim sRVal : sRVal = _ "File @Folder@\@File@:~Some*EDI*Data~TRN*2*BR0@File@@Folder@_FACILITY_Numeric*9526002033~Some*EDI*Data~" getDTmpl = sRVal End Function
I just Ran the "SEEKLINK" and the output matched with your output
***********OUTPUT**************************
ok, seekLink() was called. Searching in ------------------------------------------------------------ File @Folder@\@File@:~Some*EDI*Data~TRN*2*BR0@File@@Folder@_FACILITY_Numeric*9526002033~Some*EDI*Data~ ------------------------------------------------------------ Link: |2|BR0@File@@Folder@_FACILITY_Numeric|9526002033|
Processing all files in Folder .\FolderA ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test1.edi Link: |2|BR01A_FACILITY_Numeric|9526002033| ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test2.edi Link: |2|BR02A_FACILITY_Numeric|9526002033| ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test3.edi Link: |2|BR03A_FACILITY_Numeric|9526002033| ------------------------------------------------------------
ok, frsLoop() was called. Processing all files in Folder .\FolderA ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test1.edi Link: |2|BR01A_FACILITY_Numeric|9526002033| ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test2.edi Link: |2|BR02A_FACILITY_Numeric|9526002033| ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test3.edi Link: |2|BR03A_FACILITY_Numeric|9526002033| ------------------------------------------------------------ Processing all files in Folder .\FolderB ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\test1.edi Link: |2|BR01B_FACILITY_Numeric|9526002033| No FolderA file to compare to this FolderB File ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\test2.edi Link: |2|BR02B_FACILITY_Numeric|9526002033| No FolderA file to compare to this FolderB File ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\test3.edi Link: |2|BR03B_FACILITY_Numeric|9526002033| No FolderA file to compare to this FolderB File ------------------------------------------------------------
Step 3: I copied Test2.edi files from Folder A and copied to folder B and named CopyA2.edi
ok, frsLoop() was called. Processing all files in Folder .\FolderA ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test1.edi Link: |2|BR01A_FACILITY_Numeric|9526002033| ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test2.edi Link: |2|BR02A_FACILITY_Numeric|9526002033| ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test3.edi Link: |2|BR03A_FACILITY_Numeric|9526002033| ------------------------------------------------------------ Processing all files in Folder .\FolderB ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\copyA2.edi Link: |2|BR02A_FACILITY_Numeric|9526002033| Link BR02A_FACILITY_Numeric found. We have to compare: C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\copyA2.edi C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test2.edi Easy: the files are identical! ------------------------------------------------------------
can you check, whether it works for you (I think you see, why I didn't want to change the folders at this stage).
The next step may be harder: This is my current version of EdiComp, incorporating the info you gave about the Link/TRN problem. Save it as "EdiComp-02.vbs" and exercise it (createTD, (findLink), frsLoop, prepcomp, frsloop).
Look at the code; some higlights:
new testdata:
' ############################################################################ ''# getDTmpl - fake EDI test file content ''# todo: better EDI format; get a public sample and insert the ''# link part ''# update: ~TRN*2* resp ^TRN*2* marks the Link, more than 1 TRN possible ''# use an Array now (more lucid) ' ############################################################################
Function getDTmpl() Dim aRVal : aRVal = Array( _ "File @Folder@\@File@:" _ , "Some*EDI*Data" _ , "TRN*2*BR0@File@@Folder@_FACILITY_Numeric*9526002033" _ , "Some*EDI*Data" _ , "TRN*3*NotALinkButMatchForOldPattern*9526002033" _ , "Some*EDI*Data" _ ) getDTmpl = Join( aRVal, "~" ) End Function
cscript //D EdiComp.vbs frsloop ok, frsLoop() was called. Processing all files in Folder .\FolderA ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test1.edi Link: |2|BR01A_FACILITY_Numeric|9526002033| ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test2.edi Link: |2|BR02A_FACILITY_Numeric|9526002033| ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test3.edi Link: |2|BR03A_FACILITY_Numeric|9526002033| ------------------------------------------------------------ Processing all files in Folder .\FolderB ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\changedA2.edi Link: |2|BR02A_FACILITY_Numeric|9526002033| Link BR02A_FACILITY_Numeric found. We have to compare: C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\changedA2.edi C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test2.edi Now do a detailed compare! ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\copyA2.edi Link: |2|BR02A_FACILITY_Numeric|9526002033| Link BR02A_FACILITY_Numeric found. We have to compare: C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\copyA2.edi C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test2.edi Easy: the files are identical! ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\test1.edi Link: |2|BR01B_FACILITY_Numeric|9526002033| No FolderA file to compare to this FolderB File ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\test2.edi Link: |2|BR02B_FACILITY_Numeric|9526002033| No FolderA file to compare to this FolderB File ------------------------------------------------------------ Searching in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\test3.edi Link: |2|BR03B_FACILITY_Numeric|9526002033| No FolderA file to compare to this FolderB File ------------------------------------------------------------
got the same result.
Now i understand how the function is working...
I will make TODO LIST FOR ME and reply back to you