Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: VBScript help

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,40495
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: VBScript help
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 [2] 3 4   next >   >>
Login
Message << Older Topic   Newer Topic >>
 RE: VBScript help - 12/8/2006 7:11:15 AM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Ashok,

----------------------------- 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.

ehvbs

P.S. no hard feelings on either side I trust.

(in reply to ashok_ganeshs)
 
 
Post #: 21
 
 RE: VBScript help - 12/8/2006 7:39:18 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
I suspect the script is being run via PrimalScript (or another editro). That is where the  Exit code: 0 , 0000h comes from.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ehvbs)
 
 
Post #: 22
 
 RE: VBScript help - 12/8/2006 8:06:59 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Hi Ebhvs/Ebgreen,

I used PrimalScript to run that file...i will try thru command prompt.

Thanks
Ashok

(in reply to ebgreen)
 
 
Post #: 23
 
 RE: VBScript help - 12/8/2006 8:10:47 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
There is nothing wrong with running it rfom Primal. I was just explaining where that text came from.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ashok_ganeshs)
 
 
Post #: 24
 
 RE: VBScript help - 12/8/2006 8:34:15 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Hi Ehvbs,

----------------------------- 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.

i will go with all the things now....

Thanks once again.

Ashok

(in reply to ebgreen)
 
 
Post #: 25
 
 RE: VBScript help - 12/11/2006 2:05:14 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Hi Ehvbs,

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"

I must admit the code is pretty complex to me.

Thanks
Ashok

(in reply to ashok_ganeshs)
 
 
Post #: 26
 
 RE: VBScript help - 12/11/2006 2:46:56 AM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Ashok,

to synchronize our efforts, I propose

(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.

Good luck!

(in reply to ashok_ganeshs)
 
 
Post #: 27
 
 RE: VBScript help - 12/11/2006 2:55:08 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
HI Ebhvs/Ebgreen,

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

Thanks
Ashok

(in reply to ashok_ganeshs)
 
 
Post #: 28
 
 RE: VBScript help - 12/11/2006 3:17:43 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Hi Ehvbs,

I did the same what you ask me to do....i got the same output you posted there .

********************************************************
ok, createTD() was called.
 Zapping C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\*.*
 Creating 3 file(s) in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA
 Creating C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test1.edi
 Creating C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test2.edi
 Creating C:\wis\_vbs\0506\dev\forum\EdiComp\FolderA\test3.edi
 Zapping C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\*.*
 Creating 3 file(s) in C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB
 Creating C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\test1.edi
 Creating C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\test2.edi
 Creating C:\wis\_vbs\0506\dev\forum\EdiComp\FolderB\test3.edi
 ****************************************************************

I generated 3 testfiles (test1,2,3) in Folder A and Folder B.

Now what i suppose to do....Thanks for all your help..

Thanks
Ashok

(in reply to ashok_ganeshs)
 
 
Post #: 29
 
 RE: VBScript help - 12/11/2006 3:29:56 AM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Ashok,

(1) look at (one of) the generated files:

          File A\1:~Some*EDI*Data~TRN*2*BR01A_FACILITY_Numeric*9526002033~Some*EDI*Data~

     compare it to the code

          getDTmpl:   "File @Folder@\@File@:~Some*EDI*Data~TRN*2*BR0@File@@Folder@_FACILITY_Numeric*9526002033~Some*EDI*Data~"

           createFiles:  sD     = Replace( sD, "@File@"  , CStr( nFile ) )

     do you understand how it works?

(2) run "cscript EdiComp-01.vbs seekLink"

      how does your output compare to


      

(in reply to ashok_ganeshs)
 
 
Post #: 30
 
 RE: VBScript help - 12/11/2006 4:37:44 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Hi Ehvbs,

Now i got it, how that function works...thanks

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|
     ------------------------------------------------------------


Step 2: i ran "FRSLOOP"

***************************OUTPUT***************************************

 
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

Ran the function again" FRSLOOP"


I got the below Output

***************************OUTPUT**************************

 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!
     ------------------------------------------------------------

Advise me what i have to do the next step.

Thanks
Ashok



(in reply to ehvbs)
 
 
Post #: 31
 
 RE: VBScript help - 12/11/2006 5:13:36 AM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi 'fast worker' Ashok,

you did more steps than I told you. How can I keep up with this pace?

Now seriously: I wrote "prepcomp.bat" to easy the preparation of the
"frsloop" tests:

   copy .\FolderA\test2.edi .\FolderB\copyA2.edi
   copy .\FolderA\test2.edi .\FolderB\changedA2.edi
   echo IMDIFFERENT >>.\FolderB\changedA2.edi

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

Do you anderstand, why

    '                    TRN + Fields separated by * - remember escaping *
      oRE.Pattern    = "~TRN\*([^*]+)\*([^*]+)\*([^~]+)~"

changed to

     oRE.Pattern    = "~TRN\*(2)\*([^*]+)\*([^~]+)~"

(in reply to ashok_ganeshs)
 
 
Post #: 32
 
 RE: VBScript help - 12/11/2006 5:16:21 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Hi Ehvbs...

I Ran the other step also

 To make it a little bit more difficult:
 
     copy .\FolderA\test2.edi .\FolderB\changedA2.edi
             1 Datei(en) kopiert.
    
     echo IMDIFFERENT >>.\FolderB\changedA2.edi
 

 Running frsLoop again:
 
     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


Thanks
Ashok

(in reply to ashok_ganeshs)
 
 
Post #: 33
 
 RE: VBScript help - 12/11/2006 5:31:02 AM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Ashok,

sure, take the time you need. I know I asked a lot of 'learning new and complicated
things' of you, and you did very well.

ehvbs

(in reply to ashok_ganeshs)
 
 
Post #: 34
 
 RE: VBScript help - 12/11/2006 5:57:09 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Thanks a lot Ehvbs,


***************** Do you anderstand, why*****************************

    '                    TRN + Fields separated by * - remember escaping *
      oRE.Pattern    = "~TRN\*([^*]+)\*([^*]+)\*([^~]+)~"

changed to

     oRE.Pattern    = "~TRN\*(2)\*([^*]+)\*([^~]+)~"

******************************************************************************

A: Yes, I do Understand why you changed the Reg Exp (bcoz to pick the "TRN 2" value)

Are you a God ?...Helping people in Critical Situations...

i was reading all the queries in this forum... you,Ebsgreen,Krillian and few of  them keep on solving the problem...its unbelivable...

Thanks a lot Ehvbs.I will take little bit time to go thru this new code...once i done i will reply back to you.

Ashok

(in reply to ehvbs)
 
 
Post #: 35
 
 RE: VBScript help - 12/11/2006 6:05:10 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Yes, Ehvbs is much more thorugh than any of the rest of us I believe.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ashok_ganeshs)
 
 
Post #: 36
 
 RE: VBScript help - 12/12/2006 3:30:08 AM   
  ashok_ganeshs