Solved

Search string

Posted on 2004-10-01
13
174 Views
Last Modified: 2010-05-02
Ok I'm working on a program for personal use through work, now I'm not greatly experienced at programming but have had some practice.  What I want is when the documents for delivery are produced I want to be able to select the whole document and copy it straight to a access, I can do most like copying to clip board and placing them into access, what I'm not sure on is how to filter the clipboard. here's how normal documents look.

[Information needs to be ignored]
{Introduction} This months warehousing deliveries  for date blah blah blah

[needed information]
Day1 Warehouse1 (17:50) sent 615 to warehouse2 (32:4) for shipping
Day3 Warehouse9 (5:30) sent 758 to warehouse14 (45:5) for shipping
Day16 Customer(6:15) returned 1546(product number) back to warehouse (21:6)

The results I want from this is
if sent
The day, warehouse name and the number with the brackets around it, the number of product and the warehouse name and number, now the warehouse can be 2 or 3 words

if returned
the day, customer name and id number, product number and warehouse sent.

with this information I will place in a table.  Thanks in advance
0
Comment
Question by:gb0901a
  • 5
  • 5
  • 3
13 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
How are you putting the data into the database?

WHat does the record look like?

mlmcc
0
 

Author Comment

by:gb0901a
Comment Utility
don't worry about that, all I want is to extract the details into individual strings, that's all I would like to know how to do.

these are the records that need extracting

Day1 Warehouse1 (17:50) sent 615 to warehouse2 (32:4) for shipping
Day3 Warehouse9 (5:30) sent 758 to warehouse14 (45:5) for shipping
Day16 Customer(6:15) returned 1546(product number) back to warehouse (21:6
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
I don't think you can filter the clipboard.

This process sounds more like it should be a program that reads the document and selects only the lines you want.  Can the document be saved a s a text file with carriage returns or line feeds after each line?

mlmcc
0
 

Author Comment

by:gb0901a
Comment Utility
I know we can filter the clipboard, see I used a timer with interval at half a second to take anything from the clipboard.

This was done by

TheString = Clipboard.GetText

All I want to do is filter TheString if that's possible?
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
What does the string have in it?  Is it a single line?

mlmcc
0
 
LVL 7

Expert Comment

by:Enlade
Comment Utility


Filtering the string is just a matter of walking through the string using Mid$ and picking out what you want.  So long as the string is consistent in its format.  Still, I think that mimcc is a little confused (as am I) about why you want to use the clipboard to pass text into your application.  Why not just read it directly from a text file or something?  Or if the data is already in a DB then read the string directly from the DB.  I think it is just that we don't understand where the data is coming from and we are getting stuck on that part of your problem rather then just writing you a few loops and a few Mid$ calls to parse your string for you.

In any case, the reason we might want to know more about where the string is coming from is that the solution to this problem is dependent on the consistency of your input string (whether it is coming from a file or the clipboard).  So we are just trying to get a little more insight on the format of the input string.  For instance, you say that these are two examples of your input strings:

Day3 Warehouse9 (5:30) sent 758 to warehouse14 (45:5) for shipping
Day16 Customer(6:15) returned 1546(product number) back to warehouse (21:6)

Notice that little differences can be a problem.  For instance, you have a space after "Warehouse9", but no space after "Customer".  Or when you see the string "sent 758 to warehouse14" is that text that is typed in by a user?  For instance, what if the user typed in "sent 758 (6:15) to werehouse14"  where the user puts a "(6:15)" into the string in a place where your function might have trouble with it.

I think what you need to do is to give us a specific example of an input string and a set of output strings that you want.  For instance, lets say your input string is:

Day16 Customer(6:15) returned 1546(product number) back to warehouse (21:6)

Then you might say you want the following output strings:

Day16
Customer
6:15
returned 1546 back to warehouse
product number
21:6

I know that is probably not exactly the output strings you want, but if you list them out like I have done above then maybe mimcc could help you write out a parsing function for you.  Give him a few examples though and be precise (spaces included or not included).  Like for instance in my little example above I took out the "(" and ")" from the output strings (maybe you want them in the output strings, but that is what I mean by being precise--mimcc needs to know that).

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 7

Expert Comment

by:Enlade
Comment Utility

Oh, and give more realistic examples.  For instance, if "(product number)" is actually something like "(M6-743)" then say that.  Don't say "(product number)" in your examples.  I think it will help mimcc to be working with examples that are more real.
0
 

Author Comment

by:gb0901a
Comment Utility
OK, no probs, the (product number) is just telling what it is, so normall it's going to be a number.  Also this application is copied from a webpage produced by the company, so everything IS constant, there is no differences between formats.  So if

Day16 Customer(6:15) returned 1546 back to warehouse (21:6)

Only variables such as day, customer (6:15), product number and warehouse is going to change.

For example:

April 9th, YR04 David Bailey (6:15) returned 1546 back to Bolton On Dearne (12:15)

This would be the exact phrase the website would produce, from this I would like to copy onto clipboard, the application would then produce a database with it, al I need to know is extract the date, customer name&no, product number and warehouse name&no, sorrya bout the bad explanation
0
 
LVL 7

Expert Comment

by:Enlade
Comment Utility

Ok, so let me tell you what I'm afraid of.  I'm afraid that I'm going to write a real simple parse of the input string you gave me above.  Then when you try it on some other input strings it won't work because you haven't completely represented all possible formats of your input string.  Still, maybe we will get lucky.  Let me throw some real simple parse together for you to try.  Be right back.
0
 
LVL 7

Expert Comment

by:Enlade
Comment Utility

Ok, here is the most simple approuch to solving your problem.  It is completely dependent on the format of the input string that you gave in your example.  So, any other string that isn't in that exact same format will not return what you want.  In any case, it will either work for you or it will help you to better represent your input string format.  Here you go:

http://www.enlade.com/Samples/ParseTest4.zip

You can paste different input strings into the Public Const stParse.  Give it a try and tell me what you think.
0
 

Author Comment

by:gb0901a
Comment Utility
Ok thanks will do, whatever it will help me understand better!
0
 

Author Comment

by:gb0901a
Comment Utility
Well it works, kind of, needs some adjustments, although I'm not sure how I would do it with more than 1 record as the positions would be different wouldn't they?
0
 
LVL 7

Accepted Solution

by:
Enlade earned 500 total points
Comment Utility

So long as the features that I parsed on stay the same, but that is what I don't know.  You need to start to give more examples of all the different formats for your input string.  Try to think of all the possible formats so that we can find a pattern that can be parsed on so that you always get the information you want.

Keep in mind that it might not be possible to cover all possibilities and thus your problem will not be solvable.  It all hinges on the ability to uniquely distinguish each data item you want to extract.  If the input string has no distinguishable features then it might not be possible to parse a random like string.  But I'm thinking that your data is probably consistent enough to come up with a parse that will work.  The key is to list out enough examples of input strings to cover all that are possible and then sit back and look for the pattern.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now