Question

Read IDX file to display DBF file!

Asked by: tinh911

I'm a new one with DBF files,(FoxPro file extension?).
Every DBF file has a IDX file (index file)?, I don't know the structure of these file, please give some good link to know more about the structures of these files.
My project at university is to read the IDX file and display the content of the equivalent DBF files.
Thankx alot!

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2003-11-30 at 23:56:04ID20812405
Tags

idx

,

file

,

read

Topic

FoxPro Database

Participating Experts
4
Points
500
Comments
27

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. extension *.idx
    I found in a folder hundred of files with extension *.idx . Does anyone knows what they are?
  2. How to create a .idx file from a DBF file!
    I don't know anything about FoxPro, I just want to create .idx file from a .dbf file. When I execute these lines : USE "......\customer.dbf " EXCLUSIVE INDEX ON cno TO idxCNO.idx COMPACT I get a file called idxCNO.idx with size of 0 byte! It should contain somet...
  3. uniqueness of idx in VFP vs. DOS Foxpro?
    I have a routine in VFP which cancels a workorder. The program uses a table, then finds the workorder and replaces the product with the word "CANCEL", then deletes the record. I keep getting an error that the uniqueness of an idx has been violated when i do this i...
  4. idx
    We have database files wich end on idx the other files in de same directory have no extensions. What kind of database is this. We have to replace an old program for our program, and the customer has no idea of the used database.
  5. Importing IDX file in to Access
    Hello, I have received some IDX files. It is my understanding that these files are Indexed Foxpro file. I would either like to link them in Access or import them in to access. How can I do this? I am not sure what version of foxpro created this either. Mike
  6. Need to recreate an IDX file in visual foxpro 6
    I am trying to repair an application that has both Access and Foxpro elements. I had to rebuild the Access 97 MDF and recreate the links to Foxpro DBFs. When I recreated the Links in Access all the Indexes were there but one, and I need to recreate it. Without the link I ge...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: RanjeetRainPosted on 2003-12-01 at 01:06:34ID: 9848955

IDX files are Index files. You cannot and you do not need to read its structure.

 

by: CarlWarnerPosted on 2003-12-01 at 01:24:16ID: 9849016

All of the Fox structures are very well documented.

Assuming you want to get into the .idx file, you have a couple of places to look.

(All) VFP File Structures
http://msdn.microsoft.com/library/en-us/dv_foxhelp/html/fooriFileStructures.asp?frame=true

Index File Structure (.idx)
http://msdn.microsoft.com/library/en-us/dv_foxhelp/html/conindex_file_structure_lpidxrp.asp?frame=true

OR

Compact Index File Structure (.idx)
http://msdn.microsoft.com/library/en-us/dv_foxhelp/html/conCompact_Index_File_Structure_LPidxRP.asp?frame=true

 

by: CaptainCyrilPosted on 2003-12-01 at 01:54:13ID: 9849132

You can read everything in FoxPro. You an use Carl's links to get the structure and then write a small script to open the files in a low level format.

commands to use:

FOPEN
FREAD or FGETS
FCLOSE

 

by: RanjeetRainPosted on 2003-12-01 at 02:13:16ID: 9849204

Let me explain.

>> Every DBF file has a IDX file (index file)?,

No, that's not true. Only the files that have been indexed have an associated .IDX file. It works like this. When you create a database in FoxPro (actually a table in relational terms), it creates a .DBF file. When you index it, it creates a .IDX file. (Additional note: Foxpro can create more types of indexes).

>> My project at university is to read the IDX file and display the content of the equivalent DBF files.

I have not actually understood this. Can you please elaborate.

 

by: RanjeetRainPosted on 2003-12-01 at 02:16:38ID: 9849213

It is true that everything can be read. But reading at binary level is something no one would like to do untill absolutely needed.

I wouldn't recommend directly opening .IDX files with FOPEN (untill that's the only way out).

 

by: CaptainCyrilPosted on 2003-12-01 at 02:35:03ID: 9849279

FoxPro's default index is a .CDX file which is a compound index. Think of it as a multiple IDXs. Usually if something is wrong in the index in FoxPro we simply recreate it from the .DBF.

USE file EXCLUSIVE
DELETE TAG ALL
INDEX ON field1 TAG field1
INDEX ON field2 TAG field2
USE

This will recreate or create .CDX from a .DBF.

If you need to study the internal structure of an .IDX file, you will need to open it using FOPEN. Once I created a dbf recovery program and I needed the structure of a DBF and FPT file. If this is not what you desire, than you can open the index file like this:

USE file INDEX index.idx
SET ORDER TO fieldindexed
SCAN ALL
    ? fieldindexed
ENDSCAN
USE

 

by: RanjeetRainPosted on 2003-12-01 at 02:41:38ID: 9849303

Its easier to read the structure of a DBF file from the DBF itself. The structure of a DBF file is stored right at the beginning, before its data part begin. Back in the days of dBase III+ and FoxBase+ I had written a program in C to recover data from a corrupted DBF file using the same method.

 

by: CaptainCyrilPosted on 2003-12-01 at 02:54:08ID: 9849346

yes I agree, RanheetRain, and that's what I did. But I am assuming tinh911 wants to read how the index keys are stored in the IDX file and how to find the record number from there.

 

by: tinh911Posted on 2003-12-01 at 05:10:09ID: 9849881

Maybe all of you misunderstand!
I want to read IDX file in order to read DBF file in Visual C++, because IDX file structure is a B-Tree, this is my project at university about Data Structure.

 

by: tinh911Posted on 2003-12-01 at 05:13:13ID: 9849902

Yes, I agree with you CaptainCyril, that the thing I want, please help me!

 

by: CaptainCyrilPosted on 2003-12-01 at 05:16:55ID: 9849918

You just get the file structure from Carl's links. I did not see them personally but I am sure they are the ones, or maybe from the help in FoxPro.

Open the IDX in low-level format and get the keys as well as the B-Tree structure and the record numbers. This is as far as I can help you.

 

by: CaptainCyrilPosted on 2003-12-01 at 05:17:55ID: 9849924

This is from the help in VFP 6.0

Compact Index File Structure (.idx)
See Also

Compact Index Header Record

Byte offset Description
00 – 03 Pointer to root node
04 – 07 Pointer to free node list ( -1 if not present)
08 – 11 Reserved for internal use
12 – 13 Length of key
14 Index options (any of the following numeric values or their sums):
1–a unique index
8–index has FOR clause
32 –compact index format
64 –compound index header
15 Index signature
16 – 19 Reserved for internal use
20 – 23 Reserved for internal use
24 – 27 Reserved for internal use
28 – 31 Reserved for internal use
32 – 35 Reserved for internal use
36 – 501 Reserved for internal use
502 – 503  Ascending or descending:
0 = ascending
1 = descending
504 – 505 Reserved for internal use
506 – 507 FOR expression pool length1
508 – 509 Reserved for internal use
510 – 511 Key expression pool length1
512 – 1023 Key expression pool (uncompiled)


1 This information tracks the space used in the key expression pool.

Compact Index Interior Node Record

Byte offset Description
00 – 01  Node attributes (any of the following numeric values or their sums):
a.0 – index node
b.1 – root node
c.2 – leaf node
02 – 03 Number of keys present (0, 1 or many)
04 – 07 Pointer to node directly to left of current node (on same level, -1 if not present)
08 – 11 Pointer to node directly to right of current node (on same level; -1 if not present)
12 – 511 Up to 500 characters containing the key value for the length of the key with a four-byte hexadecimal number (stored in normal left-to-right format):
This node always contains the index key, record
number and intra-index pointer.2

The key/four-byte hexadecimal number combinations will occur the number of times indicated in bytes 02 – 03.
 


Compact Index Exterior Node Record

00 – 01  Node attributes (any of the following numeric values or their sums):
0 – index node
1 – root node
2 – leaf node
02 – 03 Number of keys present (0, 1 or many)
04 – 07  Pointer to the node directly to the left of current node (on same level; -1 if not present)
08 – 11  Pointer to the node directly to right of the current node (on same level; -1 if not present)
12 – 13 Available free space in node
14 – 17 Record number mask
18 Duplicate byte count mask
19 Trailing byte count mask
20 Number of bits used for record number
21 Number of bits used for duplicate count
22 Number of bits used for trail count
23  Number of bytes holding record number, duplicate count and trailing count
24 – 511 Index keys and information2


2 Each entry consists of the record number, duplicate byte count and trailing byte count, all compacted. The key text is placed at the logical end of the node, working backwards, allowing for previous key entries.

 

by: cbasozPosted on 2003-12-01 at 07:49:03ID: 9850831

tinh911,
Maybe you don't need the structure itself at all. Check foxpro api. It has a lot of ready functions that you can use from C (ie: _dbseek,_dbwrite,...).

 

by: cbasozPosted on 2003-12-01 at 07:50:45ID: 9850851

BTW to read a dbf you don't need its index file(s).

 

by: CarlWarnerPosted on 2003-12-01 at 10:23:57ID: 9851903

All of those functions to read .dbfs and .idx files, etc., are already written and done in C in the CodeBase C library that many C developers use to get to Fox data.  I worked with a C programmer about 12 years ago who used exactly that library back when we were still in FoxPro for DOS and he was working in the Microstation CAD environment using data interactively from and to FoxPro for DOS.  The CodeBase library worked great for him.

CodeBase (by Sequiter Software, Inc.)
http://www.sequiter.com/products/

FoxPro, dBASE & Clipper File Compatibility: A High-Performing Standard
****************************************************
CodeBase-powered applications are multi-user file compatible with FoxPro, dBASE and Clipper (xBASE). You can read and write the data, index and memo files of xBASE at the same time as xBASE.

Enjoy great performance using xBASE files for several reasons. First, the internal xBASE algorithms are simple and efficient, and the database files compress well which minimizes disk I/O. The format also lets you split a database across different disk drives allowing you to increase disk I/O throughput as much as necessary. Finally, operating system disk defragmentation utilities work excellently on xBASE files which allows maximum efficiency.

The xBASE database format is one of the most popular in the world. Thousands of software products either use or import/export data in the xBASE format. Consequently, you can use CodeBase with many development tools and applications.

SQL programmers will appreciate the unique record number field with super fast record retrieval (no index is required) and no storage overhead. One last benefit for xBASE programmers is that the corresponding API option will be intuitive and easy to use.

There is a freely downloadable CodeBase speed demo at the following URL:

http://www.sequiter.com/downloads/

 

by: tinh911Posted on 2003-12-01 at 23:43:27ID: 9856384

IDX file is actually a B-Tree, I have to write functions to add keys, delete key, search for keys.... on the IDX files(or the B-Tree data structure), I think the DBF file is not important here, right?

 

by: CarlWarnerPosted on 2003-12-02 at 00:04:27ID: 9856495

Well, I wouldn't say the data is not important.  

But, as you say, you are concentrating on the index scheme of things because that is your assignment.

If you are looking at keys that are not just GUID references or sequential primary keys with no meaning, then the data part is of little use in this context.  However, if for other reasons you are indexing (or someone else has indexed) on other columns in the data that are a bit unusual and you get unusual results in your idx functions, you may have to look at the source data to see why the idx file is the way it is.  

So, I guess, as usual, it depends.

 

by: cbasozPosted on 2003-12-02 at 00:15:34ID: 9856538

I don't see the point why you need to do that. DBF file is important there (each key value also has a pointer to record) and Fox does that when you add,delete, modify records.
If you strip doing IDX updates from DBF itself you'd be travelling back in history when IDX files were separate from their DBF and users were easily falling into mistake not to open and update them too.
If you'd still do Foxpro indexes are somewhat B Tree indexes. Check structure.

 

by: tinh911Posted on 2003-12-02 at 00:37:45ID: 9856622

I agree with you cbasoz but, in this "particular" situation I have to do that kind of jobs.

To:CarlWarner.
Where can I get the source of C Library of CodeBase to do my jobs!

 

by: CarlWarnerPosted on 2003-12-02 at 01:00:47ID: 9856693

<< Where can I get the source of C Library of CodeBase to do my jobs! >>

Other than purchasing it, I really don't even know who has it currently.  It's been a long time since I worked with that C programmer who had access to it and I don't even know where he works today.

Maybe some searching on the 'net will get you in contact with someone who is actively using it.

 

by: cbasozPosted on 2003-12-02 at 02:08:53ID: 9856987

IMHO codebase is old for the job. Structures has gone well modification since that (OTOH I don't know if has newer releases that can handle those changes)

If you have VFP read IDX file structure (and compact index file structure) sections on online help or from MSDN help. For a C coder they're quite easily understandable.

You might do a simple trick and read only the key expressions, build the tree yourself, rather than trying to sort out from IDX. With multiple tags in a single file it might get harder to sort out from IDX itself.

PS: Recently few use IDX files but CDX.

 

by: CaptainCyrilPosted on 2003-12-02 at 03:35:52ID: 9857271

Dear tinh911,

you can do the code yourself. Just use the structure that I copied for you from VFP Help. I did it for the dbf and fpt. It's just the structure you have to decipher.

You can start by opening the idx in lowlevel format and then printing the keys and following the index to the next node. Once you got that done the rest is easy to add and delete keys.

I did that once in C back in 1990. It was my assignment as well. But unfortunately I don't have the code. I left the code in the States. I did it using double level and triple level pointers in C. That's what I remember from back then. It was fun.

 

by: cbasozPosted on 2003-12-02 at 07:52:48ID: 9859092

As per the Codebase, try www.sequiter.com and www.codebase.com.
As I could see their page is new and seemingly supporting newer VFP format.
Mine version is old and on the shelf in dust at home.
I sorted out as Captain said and wrote my own routines mostly in foxpro and  some in C (compiled as a plb and fll then but never did it for the idx itself as I could simply delete and recreate all the tags).

 

by: CarlWarnerPosted on 2003-12-03 at 19:33:48ID: 9871944

IDXView 1.0
*********
IDXVeiw is a Windows utility for viewing index files FoxPro (.IDX and .CDX).Opportunities of the program:- viewing files *.IDX (uncompressed and compact) and *.CDX (compound);- a conclusion of structure of a file (heading, tags, nodes, pages);- a conclusion of the information on the chosen node, tag or page (attributes, expression of a key, the list of keys and numbers of records etc.);- a conclusion of contents of the chosen node in Hex a format;- are supported OEM and ANSI codings;- support not only keys having type CHARACTER, but also NUMERIC, DATE etc.).

http://www.brothersoft.com/Utilities_Miscellaneous_IDXView_3753.html

Besides Sequiter's CodeBASE,

C Libraries for using .DBF and index files include:

herCules
APIS Software
Frankfurt/Main, Germany

Includes source code, understands NDX, MDX, NTX, and IDX
files.  Supports DOS, Windows, OS/2, and UNIX/XENIX.
 
SoftC Database Library
SoftC, Ltd.
Anoka, Minnesota USA

Source code and Windows DLL included.
Supports DOS, Windows, OS/2, and UNIX/XENIX.

 

by: tinh911Posted on 2003-12-04 at 06:19:49ID: 9874583

Dead link!
Can you send it to me at tinh911@yahoo.com
ASAP!
Thankx

 

by: tinh911Posted on 2003-12-04 at 06:21:24ID: 9874589

Sorry I got it!
Thankx
I give you my points!

 

by: CarlWarnerPosted on 2003-12-04 at 07:13:11ID: 9874931

Thanks and you're welcome.  Good luck with your project.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...