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
#32827 - 11/17/09 10:09 AM Data Selection - How to select floating data
Dave Gould Offline
Junior Member

Registered: 11/17/09
Posts: 3
Loc: verwood
Hello im trying to select a six digit number to be used by PP7 as a variable in WATCH

i have achived this before however in this case the data is not static, infact the data is added manually for example the line always starts

concerning customer DEALERNAME 123456 (DEALER NUMBER)

I have been able to use line conditions and character filtering inorder to display this six digit number.

What I need to do is workout a way to get this six digit number into watch so it can be defined as a vaiable

Any ideas ??

Dave

Top
#32828 - 11/17/09 01:36 PM Re: Data Selection - How to select floating data
Anonymous
Unregistered


Dave,

Unfortunately PlanetPress Design can't actually pass any parameters back to Watch, though it can read from Watch easily.

My best suggestion here would be to recreate your character filtering within a VBScript, to which you pass on the line where the dealer number is located (assuming the line itself is always the same even if the position on the line is different), and VBSCript can return the 6-digit number.

You would start by doing a "Set Job Infos and Variables" and set either a job info or a local variable to the contents of the line you want to search.

You then create a new "Action" VBSCript plugin, and paste the following code in it:
Code:
' ////////////////////////////////////////////
' // Number Finder, will detect a number of a specified number of digits within a string.
' //
' // Written by: Eric-Sebastien Lachance, Objectif Lune.
' // Version: 1.0.0
' // Date: November 17th 2009
' // Input: Job info or variable containing the string to search. (type = String)
' // Output: Job info containing the number found in the string. (type = String)
' //
' ////////////////////////////////////////////

' Configuration:
' Number of digits to look for (any valid integer)
intNumberofDigits = 6

' Incoming String. Can be Watch.GetJobInfo(N) or Watch.GetVariable("VarName")
strSearchString = Watch.GetJobInfo(7)
' strSearchString = Watch.GetVariable("SearchString")

' Return string has to be Job Info (1 through 9)
intReturnJobInfo = 5

' Set to True to log messages, False for "silent" mode
bolWriteLog = False

' Message to write in log (will precede the number found)
strLogMessage = "Dealer Number found and stored in %" & intReturnJobInfo & ": "

' //////////////////////////////////
' // DO NOT EDIT AFTER THIS LINE! //
' //////////////////////////////////

Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.Pattern = "\d{" & intNumberofDigits & "}"

Set colMatches = objRegEx.Execute(strSearchString)

If colMatches.Count > 0 Then
   For Each strMatch in colMatches
       strNumberFound = CStr(strMatch.Value)
   Next
   If bolWriteLog Then
    Watch.log strLogMessage & strNumberFound,2
   End If
    Watch.SetJobInfo intReturnJobInfo, strNumberFound
    Watch.Log "JobInfo/Variable %" & intReturnJobInfo & " is set to " & strNumberFound,3
End If
Hope this helps,
Eric

Top
#32829 - 11/18/09 12:27 PM Re: Data Selection - How to select floating data
Dave Gould Offline
Junior Member

Registered: 11/17/09
Posts: 3
Loc: verwood
Thanks Eric, good to hear from you again:)

theres a problem with that? Im afraid its the assuption "(assuming the line itself is always the same even if the position on the line is different)"

the only constaints that the string Im looking for

is 6-digits long
is preceded by "concerning customer"
is begun on column 6

everything else is up for grabs? it can appear on any page (most commonly 2) it can appear on any line?

Objectifflune UK have given me this code to try, but its a bit wordy and involves changing the objective abit, looking at doing a database lookup once the infomation is found rather than finding the info and using it as a variable

'********************************************************************
' Simple VBScript that does a lookup into a database for the account
' number of a company and tags one or more resulting fields onto the
' end of a line so that it can be used in a PP form.
'
' This is only a commented sample to give you an idea of what you need
' to do, so don't expect it to run within your environment without
' modification.
'
'********************************************************************
' Original file by Adrian Shaw in about 2005
' Comments added by CFB 2009
'
'********************************************************************
' Variable declaration
'********************************************************************
Option explicit
Dim objFSO
Dim objDatabase
Dim objInputFile, objOutputFile
Dim strTempName, strTempPath, strLine, strField1Txt, strSearchField
'
' Create the Database, File System and input text file Objects
'
Set objDatabase = CreateObject("ADODB.RecordSet")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInputFile = objFSO.OpenTextFile(PW_GetJobFilename, 1)

'********************************************************************
' Main
'********************************************************************

' Get the temp path and file name. This is where watch stores working
' copies of the original job file - you can safely store temporary
' files in the same place.

strTempPath = objFSO.GetFile(PW_GetJobFilename).ParentFolder.Path
strTempName = objFSO.GetTempName

' Create an opened temp output file

Set objOutputFile = objFSO.GetFolder(strTempPath).CreateTextFile(strTempName)

' Read the input file line by line, adding the company name to its
' corresponding email address line in the output file

Do While objInputFile.AtEndOfStream = false
strLine = objInputFile.ReadLine

' Select the correct record from the database - you need to ensure that the WHERE clause
' is unique and selects only one company - something like account number should do. In this case
' the company name is used which could be a bit ambiguous and result in more than one
' record being returned in the result set.
' This also assumes that the company name is the only thing on the line. You may need to extract the
' search field (e.g. Account Number) from the string.

' Lets say that the line you're looking for normally looks like this:-

' THIS BILL REFERS TO ACCOUNT NUMBER 123456789

' Your program would need to recognise this and extract the account number for use in the lookup. This
' would give you something like:

' if you see "THIS BILL REFERS TO" starting at column 6 then get the characters between column 42 and 51 and
' use those to search for a record in the database. So this would be allocated to strSearchField

' Open the database and do the selection

objDatabase.Open "SELECT [Company Name],[Company Address],[Company email] FROM Info WHERE Info.[Company Account Number] = '" & strSearchField & "'", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\PlanetPress Suite 3\PlanetPress Watch\Samples\Contacts.mdb;Persist Security Info=False"
'
' Here you need to allocate and pad out all the fields you are returning from the database.
'
' NB the string(50," ") pads the field out with spaces and keeps the result fields in line.
'
strField1Txt = left(objDatabase.Fields(0).Value & string(50," "),50)
objOutputFile.WriteLine(strLine & strFieldTxt)

objDatabase.Close

Loop

' Tidy-up after yourself

objInputFile.Close
objOutputFile.Close

' Replace the input file by the output file

objFSO.DeleteFile PW_GetJobFilename, true
objFSO.MoveFile strTempPath & "" & strTempName, PW_GetJobFileName


****

The ideal would be for watch to

look through line by line till it finds
"concerning customer"
then to extract only the 6-digit numeric string on that line?

is that possible or am I barking up the wrond tree?

Dave

Top
#32830 - 11/18/09 01:25 PM Re: Data Selection - How to select floating data
Anonymous
Unregistered


Dave,

It's actually quite possible to look through a whole file for a 6-digit number, though I'll have to leave the exercise for you to do. Here's the page that I got the information from, it has an example of how to search through a whole file (at the end):
http://blogs.technet.com/heyscriptingguy...it-numbers.aspx

The only thing you have to keep in mind is that the filename will be the job file, which can be obtained through the following line:
Set objFile = objFSO.OpenTextFile(Watch.GetJobFilename, 1)

By the way, this will find *any* 6-digit number in your file, regardless of where it is and whether or not there are other numbers around (it'll find 167843 in a 4984132167843 string too!)

To be very honest Dave, I think that trying to automate a process based on manual user input that's subject to change in every single file is definitely not the way you should be going. Creating a standardized input for all your users would be a much more effective way to spend your time... This is my personal opinion of course.

Hope this helps,
Eric.

Top
#32831 - 11/19/09 03:53 AM Re: Data Selection - How to select floating data
Dave Gould Offline
Junior Member

Registered: 11/17/09
Posts: 3
Loc: verwood
Cheers Eric smile

Ive approached that idea with staff, due to the ideosyncronies of our CRM im "stuffed"

Thanks for your input though...

DAVe

Top