Acess,
I notice a commonality that might help. This is a little tricky, but has worked for me before, others may have a better solution, but here's mine:
Create a table (free table is fine) with the following structure:
Tablename: ImportAddr
Field1: Data C80
That's should cover the longest line you have. (Probably overkill, but you'll want that for this one).
Now, the commonality is that you have a numeric field with some leading spaces. It looks like you could have 4 or 5, but let's say you've always got 3, and none of the other lines have spaces as leading characters (or at least not 3 of them.) That is your trigger. When you see 3 leading spaces, you know you have a new record. Now, I assume you are okay to keep the name as one item, but you can parse each as you need now. Do something like this:
USE IMPORTADDR
ZAP
APPEND FROM <myImportFile.txt> SDF
GO TOP
DO WHILE NOT EOF()
lnCount = 1
lnCurRec = RECNO()
SKIP
DO WHILE LEFT(DATA,3) # ' '
lnCount = lnCount +1
SKIP
ENDDO
GO lnCurRec && Go back to start of this address rec.
* At this point, we now know whether we're dealing with 4 or 5 lines for address. Also, I'll assume that we don't need to parse the lines beyond one field, but you can do that if you need to.
SELECT <TableToUpdate>
APPEND BLANK && I assume you want to create this record
SELECT IMPORTADDR
REPLACE TableToUpdate.CodeValue WITH IMPORTADDR.DATA
SKIP
REPLACE TableToUpdate.NameValue WITH IMPORTADDR.DATA
SKIP
REPLACE TableToUpdate.Addr1Value WITH IMPORTADDR.DATA
SKIP
IF lnCount = 5
REPLACE TableToUpdate.Addr2Value WITH IMPORTADDR.DATA
SKIP
ENDIF
REPLACE TableToUpdate.CityStateZip WITH IMPORTADDR.DATA
SKIP
ENDDO
*
You may need to tweek this a bit to get your desired results, but this should set you well on your way.
Best Regards,
Scott
"Everything should be made as simple as possible, and no simpler."
![[hammer] [hammer] [hammer]](/data/assets/smilies/hammer.gif)