Indexing a DBF

Moderator: Rathinagiri

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

Indexing a DBF

Post by asharpham » Sun Mar 25, 2018 12:30 pm

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: 247
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 6 times
Been thanked: 22 times

Post by trmpluym » Sun Mar 25, 2018 1:16 pm

I use:

USE <dbf> NEW SHARED INDEX <index>

But can you post a sample ?

User avatar
serge_girard
Posts: 2361
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 609 times
Been thanked: 124 times
Contact:

Post by serge_girard » Sun Mar 25, 2018 2:08 pm

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

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

Post by asharpham » Sun Mar 25, 2018 4:03 pm

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: 502
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 137 times
Been thanked: 411 times

Post by edk » Sun Mar 25, 2018 4:27 pm

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
Has thanked: 14 times

Post by asharpham » Sun Mar 25, 2018 4:43 pm

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
Has thanked: 14 times

Post by asharpham » Sun Mar 25, 2018 5:26 pm

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: 2361
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 609 times
Been thanked: 124 times
Contact:

Post by serge_girard » Sun Mar 25, 2018 6:01 pm

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

User avatar
mol
Posts: 3247
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 230 times
Been thanked: 132 times
Contact:

Post by mol » Sun Mar 25, 2018 7:31 pm

Use this code:

Code: Select all

Append blank;
Replace;
  Field1 with Form1.Text1.Value,;
  Field2 with Form1.Text2.Value

User avatar
dragancesu
Posts: 714
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 24 times
Been thanked: 149 times

Post by dragancesu » Sun Mar 25, 2018 9:23 pm

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