Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
They always move the goal-posts, don't they
Message
From
05/07/2005 10:27:45
 
 
To
05/07/2005 09:51:59
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01028919
Message ID:
01028988
Views:
11
Thanks for that Dragan. Again, I suspected I'd have to do something as nasty, involved and faffy as this, but was hoping someone would say something like "Use the VFP ConvertTheirDataToYoursInAnyFormat() function" Suppose I'll have to wait for VFP 12 for that! :-)

Terry

>I've dealt with this before. The major point in the app was a huge import file which came from an external app that I had no control over. Worse: I never knew what these guys would do next.
>
>So I had a metadata table. Their field name, my field name, my table name (i.e. their data were highly denormalized, and contained lists within a field etc - so I exported into several tables), field type, field len (don't remember if I had any decimals anywhere), conversion function.
>
>Before import, I'd read the header, split it into the field names (alines() with a tab for field separator - in your case it'd be the bar). Then I'd go down my metadata table and match these fields to it, and generate a cursor with appropriate structure (if not found, FLDnnn c(10)). Then I'd append into that cursor. The nice thing was that if any fields weren't there, nothing would happen.
>
>In the second phase I'd generate code to write into the record(s) of the target table(s) - which meant that no code was generated for absent fields. I've once calculated that just this "no code generated for absent fields" eliminated about 40000 if/endifs, because the code wouldn't have to check for each of those fields for each record. What was there was there, what wasn't wasn't.
>
>There was one trick to the generated code: the conversion functions were actually methods of the converter bizobject, and the bizobject would pass itself as a parameter. So the code would look like
>
>
lparam oThis
>oThis.CharToDate(curImportTemp.cDate, "bigimporttable.dDate")
>oThis.JustCopy(curImportTemp.cName, "bigimporttable.cName")
>...
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform