IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#19028 - 08/13/06 06:18 PM Jobinfo variable
JFP Offline
Junior Member

Registered: 08/13/06
Posts: 2
Loc: California
I am looking for a way to search for a string in a data file in Watch for 8 characters after a certain string is found.
Example: Inside the data file is a string that looks like "file #: 243746-9". And I need to capture just the 243746-9 and apply it to the jobinfo 1, so jobinfo 1 will be set to 243746-9.
The data file is split every 60 lines and within every 60 lines will be a new "file #:******-*"

Thanks,
JIM

Top
#19029 - 08/14/06 06:33 AM Re: Jobinfo variable
stuartg Offline
OL Expert

Registered: 03/06/03
Posts: 713
Loc: Swindon, England
The easiest way to look for stuff like this is to use a regular expression.
The following link is useful for the use of a scripting regular expression object Regular Expression Object and this one descibes the possible regular expressions themselves Regular Expressions .

Here is a code segment I used in a similar situation. Once the input file has been split into pages you should be able to fit the whole of each file into a Vb string variable (64k max). This means it can be read in one go which avoids a lot of messy code.

Code:
 
strFileName=Watch.GetJobFileName()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileName,1)
strContents = objFile.ReadAll
objFile.Close

Set regEx = New RegExp   ' Create regular expression.
regEx.Pattern =  "file #: \d{6}-\d"  ' Set pattern.
regEx.IgnoreCase = False   ' Set case insensitivity.
regEx.Global = True   ' Set global applicability.
set matches = regEx.Execute(strContents)   ' Execute search.

If Matches.count = 0 Then
  'no match
  Watch.SetJobInfo 1,"NO MATCH"
Else
  Watch.SetJobInfo 1,right(Matches(0).Value,8)
End if
Hope this helps
Stuart

Top
#19030 - 08/15/06 02:19 AM Re: Jobinfo variable
JFP Offline
Junior Member

Registered: 08/13/06
Posts: 2
Loc: California
That helped a lot.
Thanks for the links also. Gives me some good reading.

Thanks Stuart

Top