PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → [WD5.5] Field exists
[WD5.5] Field exists
Débuté par Patrick Vandebroek, 15 déc. 2004 10:48 - 4 réponses
Posté le 15 décembre 2004 - 10:48
Hi All,
I have a procedure to import data from a Dbase file, but there is a problem with older versions where fields are not existing.
Can I check in WD5.5 if a field exists in a Dbase file?
Regards,
Patrick
Posté le 16 décembre 2004 - 00:49
Hi All,
I have a procedure to import data from a Dbase file, but there is a problem with older versions where fields are not existing.
Can I check in WD5.5 if a field exists in a Dbase file?
Regards,
Patrick

Why not have several dbase file definitions available and ask the user at runtime which version is to be used?
hth
Clive
Posté le 16 décembre 2004 - 00:49
Hi Patrick,
you can open the DBF File with fOpen and seek for the Fieldname lets say in the first 500 Bytes. To be exact: (Number of fields + 1) * 32 Bytes = app. size of header.
Here you find a descrition of the DBF Header:
http://www.cs.cornell.edu/Courses/cs212/2001fa/Project/Part1/dbf.htm
Peter

Hi All,
I have a procedure to import data from a Dbase file, but there is a problem with older versions where fields are not existing.
Can I check in WD5.5 if a field exists in a Dbase file?
Regards,
Patrick
Posté le 17 décembre 2004 - 17:19
Why not have several dbase file definitions available and ask the user at runtime which version is to be used?
hth
Clive

That was also my first intention, till I realised what a mess this was.
In the past, nobody had ever wrote any documentation.
There are over 1000 clients who used the older versions of this program and there are clients which had the same version, buth the file defintion is different.
I don't have an overview of the file definition on each version, and if I had a file definition, it still can be different by several clients.
You see why I need to check if a field is existing.
Regards.
Posté le 17 décembre 2004 - 23:07
G'day Patrick
As an alternative to the Fopen option, there are dbase commands to list a file structure, so you could not run a short dbase program to open each file and list its structure to a text file, then read the text file in WD5.5 to get the structure and modify your read in program accordingly to include or skip missing fields.
I had a similar problem a few years ago and I simply built a master set of dbase files with all the possible fields for each file then at each site I ran a dbase program to append the data into my files and then read in from them.

Regards
Al