Hello Everyone,
I'm new to posting in this group and was hoping that I might be able to
get some assistance with an issue that I'm having.
Basically, what I'm doing is capturing AS/400 data with a software
called PlanetPress Watch and when I get this data I need to run it
through a VBScript to look for Index Values that will be grabbed and
passed to a variable, then eventually using the variables to create
delimited data file with path to a PDF, i.e.
"field1"~"field2"~"field3"~@@path\pdf.pdf.
My problem is that I've changed the script from using SkipLine and
Skip, just in case an extra CRLF or something appears in the data,
which would throw off the entire script in the fact that my Index
values would be blank. I've recently discovered the power of RegExp
and have been researching it over the past week to try and get a handle
on it. I think I'm to the point of understanding it, but am having
some issues with getting it to work in a VBScript. Part of my problem,
other than being a self-taught programmer, is reading in the data file
and passing it to a variable with the .ReadAll command. I think I may
have the .ReadAll command now, but it's the RegExp pattern that isn't
matching or something, even though it should match this: "CR\LF
ACLU5801S2341380", that is CR LF Space String.
Here's my code:
'**************************************************************
Option Explicit
Const ForReading = 1, ForWriting = 2
Dim x
Dim objFSO
Dim objInputFile, objOutputFile, objIn
Dim strTempName, strTempPath
Dim strLine, strLineBack1, strLineBack2
Dim ContainerNo, insertValue
Dim PhxRef, locationNumber, statementDate, counter, TypeBrokerage,
TypeBreakbulk
Dim DocNoP1, DocNoP2, DocNoP3, DocNoP4, DocNoP5, DocNoP6
Dim ShipperNo, ConsigneeNo, HAWBNo, AgentNo, AWBDate, MBillNo, HBillNo
Dim DocNoP11, DocNoP22, DocNoP33, DocNoP44, DocNoP55, DocNoP66
Dim fcount, lncount, skipln, strData, objIntro, strLineIn, DataLine
Set objFSO = CreateObject("Scripting.FileSystemObject")
'***NOTE: PW_GetJobFilename is a special function for PPW, that gets
the tempFileName of the datafile
Set objInputFile = objFSO.OpenTextFile(PW_GetJobFilename, 1)
strTempPath = objFSO.GetFile(PW_GetJobFilename).ParentFolder.Path
strTempName = objFSO.GetTempName
Set objOutputFile =
objFSO.GetFolder(strTempPath).CreateTextFile(strTempName)
Dim ss, re, rv, objMatch, ColMatches, StrReturnStr
Set re = New RegExp
re.Pattern = "(\r\n\x20)([A-Z\d]{12,18})"
're.Pattern = "c."
re.Global = True
re.IgnoreCase = True
'Set objInputFile = objFSO.OpenTextFile(PW_GetJobFilename, 1)
Do While objInputFile.AtEndOfStream <> True
strData = objInputFile.ReadLine
'***NOTE: Watch.ShowMessage is a special function for PPW, like MsgBox
'Watch.ShowMessage(strData)
Set ColMatches = re.Execute(strData)
Loop
For Each objMatch in ColMatches
StrReturnStr = objMatch.value
Watch.ShowMessage(StrReturnStr)
Next
'Loop
Watch.SetJobInfo 1, Chr(34) & "INV" & Chr(34) & Chr(126) & Chr(34) &
DocNoP1 & DocNoP2 & DocNoP3 & DocNoP4 & DocNoP5 & DocNoP6 & Chr(34) &
Chr(126) & Chr(34) & ShipperNo & Chr(34) & Chr(126) & Chr(34) &
"ConsigneeNo" & Chr(34) & Chr(126) & Chr(34) & "BOLNo" & Chr(34) &
Chr(126) & Chr(34) & "AgentNo" & Chr(34) & Chr(126) & Chr(34) & "Date"
& Chr(34) & Chr(126) & Chr(34) & "DocNo2" & Chr(34) & Chr(126) &
Chr(34) & "ContainerNo" & Chr(34) & Chr(126) & Chr(34) & HAWBNo &
Chr(34) & Chr(126) & Chr(34) & HBillNo & Chr(34) & Chr(126) & Chr(34) &
MBillNo & Chr(34) & Chr(126) & Chr(34) & "EntryNo" & Chr(34) & Chr(126)
& Chr(34) & "CustAcctNo" & Chr(34) & Chr(126) & Chr(34) & "ImporterNo"
& Chr(34) & Chr(126) & Chr(64) & Chr(64) & "D:\DocImport\INV\" &
Watch.GetJobInfo (9) & ".pdf"
objInputFile.Close
objOutputFile.Close
objFSO.DeleteFile PW_GetJobFilename, true
objFSO.MoveFile strTempPath & "\" & strTempName, PW_GetJobFileName
'**************************************************************
Any suggestions that you could give would be greatly appreciated.
Thanks in advance.
--Ken Stulce