|
Subject:
|
Parsing a text string
|
|
Posted By:
|
medix_911
|
Post Date:
|
2/7/2006 4:20:40 PM
|
Hello Folks,
I can't seem to get my mind around this one for some reason. I'm writing a custom package for the mobile auction industry and thought it would be cool if when they try to register a new bidder, they just use a magnetic card reader and swipe the drivers license. There in lies the problem. The data is ju,bled together and there is no common delimiter. Any help would be greatly appreciated. I'll include the text string that comes from the mag reader with this post.
%OHHILLSBORO^JACKMAN$BRANDEN$W^224$WOODLAND$DR?;6360231810302872=000060619190612?#TS45133000000DA00000M073200BROBLURJ111111000000000000000000?
The blue is full name The brown is street address The teal is the driver's license number The orange is the postal zip code
In the form, i have a memo field to hold this string, then want to split those parts out and put them in their respective fields. Hopefully this makes sense. If anymore info is needed, please don't hesitate to ask. I'm going to keep working on this myself and maybe i'll figure it out on my own.
Branden
|
|
Reply By:
|
kindler
|
Reply Date:
|
2/7/2006 4:50:03 PM
|
From the look of the string, there are a few delimiters you can pull out. The easiest way is probably to set up variables, parse the string entering the values into those variables, and then assign them to the field values. The only ones I can't see an easy way to pull out are the license number and zip code, unless "#TS" is a common delimiter for the zip. Here's a pseudocode, I'll leave it to you to look up the exact functions and syntax.
varState = substring(inputText, 1, 2) delim = FindFirst(inputText, '^', 0) varTown = substring(inputText, 3, delim) temp = delim delim = FindFirst(inputText, '$', temp) temp = delim delim = FindFirst(inputText, '$', temp) varLastName = substring(inputText, temp, delim) temp = delim delim = FindFirst(inputText, '$', temp) varFirstName = substring(inputText, temp, delim) varMI = inputText[delim+1] temp = delim delim = FindFirst(inputText, '^', temp) temp = delim delim = FindFirst(inputText, '?', temp) varAddress = substring(inputText, temp, delim)
|
|
Reply By:
|
medix_911
|
Reply Date:
|
2/7/2006 5:06:49 PM
|
Is there a specific library i need to have installed to get the substring to work, i can't find any references on it
Branden
|
|
Reply By:
|
SerranoG
|
Reply Date:
|
2/8/2006 8:46:46 AM
|
Kindler, FindFirst() and Substring() are not Access functions. Did you create those?
Branden, look up help for functions Left(), Right(), Mid(), and InStr(). A combo of those will help you parse this.
Greg Serrano Michigan Dept. of Environmental Quality, Air Quality Division
|
|
Reply By:
|
medix_911
|
Reply Date:
|
2/8/2006 9:05:43 AM
|
I also posted this on the message boards at Utter Access and have since found a solution with the help of an individual named ace. He made it look simple and me look stupid. Thanks for all the help though. If anyone would like to see the code from the completed forms, let me know, it ended up being a couple modules and then the code for the after_update event to fire it off in the form.
Branden
|
|
Reply By:
|
kindler
|
Reply Date:
|
2/8/2006 11:19:30 AM
|
Serrano: FindFirst() actually is an Access function.. it just doesn't do what I thought. I meant to be using InStr(temp, inputText, searchChar) instead. Substring was just a pseudocode interpretation since I couldn't remember the exact syntax for Mid() and it's a pretty common function in other languages. I didn't actually create the function although.. it would be relatively easy to define using Mid().
|
|
Reply By:
|
SerranoG
|
Reply Date:
|
2/8/2006 11:32:38 AM
|
Yes, I can understand when using many programs that the syntax is different for all. Heh, heh...
To clarify using Access terms, FindFirst is actually a method (with an action), not a function that is called with arguments like a procedure. For example,
Dim rs as Object Set rs = Me.RecordSetClone rs.FindFirst "[strState] = 'Michigan'"
vs
strState = FindFirst("Michigan")
The latter is a function (which doesn't exist in Access unless you create it). The former is using the FindFirst method which Access supports assuming you have the correct library referenced.
Greg Serrano Michigan Dept. of Environmental Quality, Air Quality Division
|
|
Reply By:
|
medix_911
|
Reply Date:
|
2/8/2006 12:05:06 PM
|
In all actuality fellas, the left$, right& and mid$ methods were somewhat helpful but in of themselves would not work simply for the fact that the text is dynamic, no 2 peoples address or name are the same length. The end result used limited left and mid methods but the 2 most useful mesthods were instr and split. But thanks for your help none the less.
Branden
|
|
Reply By:
|
DeMoNN
|
Reply Date:
|
11/21/2006 12:37:12 PM
|
hey branden
paste like 10 to 20 records here and ill look for a way to get it for u
I was here but now I'm gone. I leave this messege to be carried on. Whoever knew me, knew me well. Whoever didn't, go to hell.
|