Indexing a DBF

Moderator: Rathinagiri

asharpham
Posts: 55
Joined: Sat Mar 24, 2018 2:48 pm
DBs Used: DBF

Indexing a DBF

Post by asharpham »

I'm experienced with Clipper but am an absolute novice with HMG/Harbour. My attempts to open a DBF file with an Index (NTX) utterly fails.

The line "USE <dbf> INDEX <Index>" just doesn't seem to work. The database file opens okay but not in the indexed order. I've tried a variety of methods but my understanding is still too limited to "translate" from Clipper. :(

Can someone offer a suggestion? I have a lot to learn and am happy to struggle through but occasionally I get stuck on something simple like this. By the way, I have never tried programming in a Windows environment before.

Regards,
Alan
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: Indexing a DBF

Post by trmpluym »

I use:

USE <dbf> NEW SHARED INDEX <index>

But can you post a sample ?
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Indexing a DBF

Post by serge_girard »

Hi Alan,

First: welcome from Belgium!
Theo's suggestion should work. Maybe you should reindex before. USE syntax has not changed in Harbour/Windosw/HMG so it should work.

Regards, Serge
There's nothing you can do that can't be done...
asharpham
Posts: 55
Joined: Sat Mar 24, 2018 2:48 pm
DBs Used: DBF

Re: Indexing a DBF

Post by asharpham »

Hi guys. Thanks so much for your welcome and your suggestion. I realised after I got your replies that I hadn't created the indexes for the new DBF file I'd created. I had been working off an old clipper program I wrote about 20 years ago and then decided to modify it greatly using a new database file.

So I've created 2 indexes. Is there a simple way to view the database via an Index without writing a heap of code? I can view the database with LibreOffice Calc but this doesn't give me the indexed list. I'm still very much in testing mode. :?

Alan
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Indexing a DBF

Post by edk »

Try this:

Code: Select all

use test index test1
EDIT EXTENDED WORKAREA test
asharpham
Posts: 55
Joined: Sat Mar 24, 2018 2:48 pm
DBs Used: DBF

Re: Indexing a DBF

Post by asharpham »

Thanks so much. It's easy when you know how! :D

Regards,
Alan
asharpham
Posts: 55
Joined: Sat Mar 24, 2018 2:48 pm
DBs Used: DBF

Re: Indexing a DBF

Post by asharpham »

Okay last question for the night - (Yes, it's night here in Australia) - I've set up a LABEL / TEXTBOX to get user input to be added to the database. How do I save the TEXTBOX input to the database? The old READ statement in Clipper was so simple!

Alan
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Indexing a DBF

Post by serge_girard »

Hi Alan,

Several ways:
I useally take a 'copy' of the database edit fields. Then a button in order to validate etc. and then my update with the edit-field.

Others use browse and then you can update immediatly.

So it depends on how you will edit!

Samples enough in the samples.

Serge
There's nothing you can do that can't be done...
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Indexing a DBF

Post by mol »

Use this code:

Code: Select all

Append blank;
Replace;
  Field1 with Form1.Text1.Value,;
  Field2 with Form1.Text2.Value
User avatar
dragancesu
Posts: 921
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Indexing a DBF

Post by dragancesu »

Hello asharpham

HMG uses a clipper syntax and the transition should be relatively easy but as it says: every start is difficult

Believe that we all passed it, but the effort is worth it, you will get a lot

Look at the topic I've opened a long time ago, a program that will generate a simple program to work with your dbf table

http://hmgforum.com/viewtopic.php?f=10&t=4170
Post Reply