Indexing a DBF

Moderator: Rathinagiri

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

Re: Indexing a DBF

Post by asharpham »

Thanks so much for your assistance, guys. As I read other people's code I realise how long it is since using Clipper!

Dragan, I read through your "quickgen" code and am a little baffled by where some of the keywords come from. I downloaded the HMG/Harbour tutorials but I can't find any reference to "SET NAVIGATION" in any of them (including Clipper). Also, just for clarification, "SELECT 0" opens the next available workarea? Is this still the case if there is 1 or more workareas already open?

Mol, your code is simple and straightforward. Is the "dbAppend()" the same as "Append blank"?

How do I code so that items on the screen remain centred irrespective of the user resizing or maximising the screen?

And finally, I have a window that has a heading and other information; how do I clear the window of all info except for the heading? In Clipper there was CLS (or CLEARSCREEN) which cleared the entire screen and it was easy enough to add the heading back in.

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

Re: Indexing a DBF

Post by asharpham »

Sorry Mol but I got a syntax error on your code. My database is named LIBRARY and it has 2 indexes, iTITLE & iARTIST. The window calling this procedure is Library_2 and it is a child window.

Here is the code for appending the new entry:

FUNCTION AddEntry(cTitle,cArtist)
IF cTitle > " "
nLastTrackNumber := nLastTrackNumber+1
SET INDEX TO iTITLE, iARTIST
dbAppend()
Replace;
LIBRARY->TRACKNUM with Library_2.nLastTrackNumber.Value,;
LIBRARY->TITLE with Library_2.cTitle.Value,;
LIBRARY->ARTIST with Library_2.cArtist.Value
SET INDEX TO
ENDIF
RETURN

There are no errors generated but no matter what I try, nothing is appended to the database - not even a blank entry.

Regards,
Alan
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: Indexing a DBF

Post by CalScot »

If it's not even appending a blank, it sounds like the if condition isn't getting triggered.
Have you tried If cTtile # " " (not equal to rather than greater than, for a character field)?'
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 »

Can you upload your example? prg and dbf/ntx put in zip and attach in message

Something like DBU is here

http://hmgforum.com/viewtopic.php?f=10& ... t&start=50
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Indexing a DBF

Post by andyglezl »

Hola

Creo que para todos aquellos que empiezan a querer migrar sus programas, tienen que leer y tratar de entender
como es el proceso de este cambio (forma de programar) y si es con solo HARBOUR (antes clipper)
ó con HMG (de forma Gráfica ).
y pueden empezar por compilar todos los ejemplos que vienen con HMG.
Además darle una revisada a los post que hay el foro como los siguientes:
-------------------------------------------------------------------------------------------------------------------------------------------
Hello

I think that for all those who start wanting to migrate their programs, they have to read and try to understand
how is the process of this change (how to program) and if it is with only HARBOR (before clipper)
or with HMG (in graphic form).
  and you can start by compiling all the examples that come with HMG.
Also give a revised to the post that there is the forum as the following:

viewtopic.php?f=37&t=3557&p=32755&hilit ... per#p32755
viewtopic.php?f=24&t=2011&p=17023&hilit ... per#p17023
viewtopic.php?f=12&t=5407&p=52771&hilit ... our#p52771
viewtopic.php?f=12&t=5407&p=52751&hilit ... our#p52751
search.php?st=0&sk=t&sd=d&sr=posts&keyw ... &start=200
viewtopic.php?f=5&t=4751&p=45265&hilit= ... our#p45265
viewtopic.php?f=5&t=4701&p=44783&hilit= ... our#p44783
viewtopic.php?f=5&t=4673&p=44487&hilit= ... our#p44487
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
serge_girard
Posts: 3166
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 »

Best way is indeed to go thru all samples, compile, execute see what happens, and examine the program!

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 »

Thanks Serge. I have been through quite a lot of sample code and have gleaned a lot but there are some things I get stuck on and just can't find the answer. That's when I come to the forum. :)

Instead of uploading a heap of code, could I ask you to have a look at the following which gives me a compiler error on the line "INDEX ON LIBRARY->TITLE TO iTITLE". LIBRARY is the database file and here I am testing whether the file exists (and creating it with its indexes if it doesn't) or if one or more of the indexes don't.

------------------------------------------
dbCloseAll()

IF !FILE("LIBRARY.DBF")
aSTRUCT := { {"TRACKNUM","N",4,0 }, ;
{"ALBUM_NO","C",6,0}, ;
{"ALBUM_TITLE","C",40,0}, ;
{"TITLE","C",33,0}, ;
{"ARTIST","C",40,0}, ;
{"ART_NO","N",4,0}, ;
{"TRACK","N",2,0}, ;
{"DUR","C",5,0}, ;
{"YR","C",2,0}, ;
{"FILENAME","C",8,0} }

dbCreate("LIBRARY",aSTRUCT)
USE LIBRARY NEW
INDEX ON LIBRARY->TITLE TO iTITLE
INDEX ON LIBRARY->ARTIST TO iARTIST
INDEX ON LIBRARY->ALBUM_TITLE TO iALBUMTITLE
INDEX ON LIBRARY->FILENAME TO iFILENAME
dbCloseArea()
ELSE
IF !FILE("iTITLE.NTX") .OR. !FILE("iARTIST.NTX") ;
.OR. !FILE("iALBUMTITLE.NTX") .OR. !FILE("iFILENAME.NTX")
USE LIBRARY NEW
INDEX ON LIBRARY->TITLE TO iTITLE
INDEX ON LIBRARY->ARTIST TO iARTIST
INDEX ON LIBRARY->ALBUM_TITLE TO iALBUMTITLE
INDEX ON LIBRARY->FILENAME TO iFILENAME
dbCloseArea()
ENDIF
ENDIF

USE LIBRARY NEW

-----------------------------------

This code appears before the first WINDOW statement and doesn't rely on any variables not shown here.

Regards,
Alan
User avatar
serge_girard
Posts: 3166
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 »

Alan,

'ALBUM_TITLE' is shortened to 'ALBUM_TITL' in dbcreate !
Fieldnames are max 10 char...

When you replace in the indexes it works well.

Serge
There's nothing you can do that can't be done...
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 »

Look and compile attacment, you'll see how your program can look

p.s structure is not good
Attachments
library.zip
(17.59 KiB) Downloaded 226 times
asharpham
Posts: 55
Joined: Sat Mar 24, 2018 2:48 pm
DBs Used: DBF

Re: Indexing a DBF

Post by asharpham »

Thanks again guys. Wow! Dragan, you've gone all out. I'll scan your code carefully and see what I can learn.

Much obliged,
Alan
Post Reply