Discussion:
Reindex appears to be packing tables!
(too old to reply)
Debbie
2004-11-03 15:25:46 UTC
Permalink
I have a reindex program that uses the ADIR() function to gather the names
of all my tables and then reindex them. Before reindexing each table, I
pass the table name to a method which tells me whether or not it is one that
can be packed at this time (it returns .T. if the table can be packed, and
.F. if it can't). My problem is that, regardless of what the method
returns, all tables get packed! I added a messagebox to tell me if I was
falling into the correct part of my code, and I was.

llpack = THISFORMSET.PackTable(lctable)
USE (lctable) EXCL ALIAS lctable
IF llpack
PACK
REINDEX
ELSE
=MESSAGEBOX("Not packing.",0) && Test
REINDEX
ENDIF
USE IN lctable

Maybe I'm missing something silly, but I'd appreciate it if anyone out there
had some suggestions! Thanks in advance.

Debbie
Craig Berntson
2004-11-03 16:45:01 UTC
Permalink
You didn't show the code in the PackTable method. However, if you can't open
the table EXCLUSIVE, you'll get an error. In addition, REINDEX is not
reliable. The key information is stored in the header of the CDX. If that
gets corrupt, REINDEX will either cause an error or create a corrupt index.
--
Craig Berntson
MCSD, Visual FoxPro MVP
www.craigberntson.com
Salt Lake City Fox User Group
www.slcfox.org
www.foxcentral.net
Post by Debbie
I have a reindex program that uses the ADIR() function to gather the names
of all my tables and then reindex them. Before reindexing each table, I
pass the table name to a method which tells me whether or not it is one
that can be packed at this time (it returns .T. if the table can be packed,
and .F. if it can't). My problem is that, regardless of what the method
returns, all tables get packed! I added a messagebox to tell me if I was
falling into the correct part of my code, and I was.
llpack = THISFORMSET.PackTable(lctable)
USE (lctable) EXCL ALIAS lctable
IF llpack
PACK
REINDEX
ELSE
=MESSAGEBOX("Not packing.",0) && Test
REINDEX
ENDIF
USE IN lctable
Maybe I'm missing something silly, but I'd appreciate it if anyone out
there had some suggestions! Thanks in advance.
Debbie
Debbie
2004-11-03 17:06:19 UTC
Permalink
I didn't list all of my code in the message I posted, but I do test to see
if the file can be opened exclusively. If it can't, I let the user know
which table and then move on to the next one listed in the array. I'm not
getting any errors, it's just packing all the tables irrespective of whether
I said it was okay to do so or not!

As for the PackTable method, it's just a simple IF...ELSE...ENDIF, ie:

IF lctable = "table1.dbf" OR lctable = "table2.dbf" OR "table3.dbf" && Etc
etc
RETURN .F.
ELSE
RETURN .T.
ENDIF

Do you have any other suggestions? Thanks!

Debbie :o)
Post by Craig Berntson
You didn't show the code in the PackTable method. However, if you can't
open the table EXCLUSIVE, you'll get an error. In addition, REINDEX is not
reliable. The key information is stored in the header of the CDX. If that
gets corrupt, REINDEX will either cause an error or create a corrupt index.
--
Craig Berntson
MCSD, Visual FoxPro MVP
www.craigberntson.com
Salt Lake City Fox User Group
www.slcfox.org
www.foxcentral.net
Post by Debbie
I have a reindex program that uses the ADIR() function to gather the names
of all my tables and then reindex them. Before reindexing each table, I
pass the table name to a method which tells me whether or not it is one
that can be packed at this time (it returns .T. if the table can be
packed, and .F. if it can't). My problem is that, regardless of what the
method returns, all tables get packed! I added a messagebox to tell me if
I was falling into the correct part of my code, and I was.
llpack = THISFORMSET.PackTable(lctable)
USE (lctable) EXCL ALIAS lctable
IF llpack
PACK
REINDEX
ELSE
=MESSAGEBOX("Not packing.",0) && Test
REINDEX
ENDIF
USE IN lctable
Maybe I'm missing something silly, but I'd appreciate it if anyone out
there had some suggestions! Thanks in advance.
Debbie
Jeroen van Kalken
2004-11-03 23:13:36 UTC
Permalink
On Wed, 3 Nov 2004 12:06:19 -0500, "Debbie" <***@hotmail.com>
wrote:

Since adir() returns filenames in uppercase, your IF statement will
probably fail. (see below)
Post by Debbie
I didn't list all of my code in the message I posted, but I do test to see
if the file can be opened exclusively. If it can't, I let the user know
which table and then move on to the next one listed in the array. I'm not
getting any errors, it's just packing all the tables irrespective of whether
I said it was okay to do so or not!
IF lctable = "table1.dbf" OR lctable = "table2.dbf" OR "table3.dbf" && Etc
change it to:
IF inlist(lower(lcTable),"table1.dbf", "table2.dbf", "table3.dbf",...)
Post by Debbie
etc
RETURN .F.
ELSE
RETURN .T.
ENDIF
Do you have any other suggestions? Thanks!
You could even shorten it to:
proc PackTable
Return inlist((lower(lcTable),"table1.dbf", "table2.dbf",
"table3.dbf",...)
Post by Debbie
Debbie :o)
Post by Craig Berntson
You didn't show the code in the PackTable method. However, if you can't
open the table EXCLUSIVE, you'll get an error. In addition, REINDEX is not
reliable. The key information is stored in the header of the CDX. If that
gets corrupt, REINDEX will either cause an error or create a corrupt index.
--
Craig Berntson
MCSD, Visual FoxPro MVP
www.craigberntson.com
Salt Lake City Fox User Group
www.slcfox.org
www.foxcentral.net
Post by Debbie
I have a reindex program that uses the ADIR() function to gather the names
of all my tables and then reindex them. Before reindexing each table, I
pass the table name to a method which tells me whether or not it is one
that can be packed at this time (it returns .T. if the table can be
packed, and .F. if it can't). My problem is that, regardless of what the
method returns, all tables get packed! I added a messagebox to tell me if
I was falling into the correct part of my code, and I was.
llpack = THISFORMSET.PackTable(lctable)
USE (lctable) EXCL ALIAS lctable
IF llpack
PACK
REINDEX
ELSE
=MESSAGEBOX("Not packing.",0) && Test
REINDEX
ENDIF
USE IN lctable
Maybe I'm missing something silly, but I'd appreciate it if anyone out
there had some suggestions! Thanks in advance.
Debbie
Debbie
2004-11-04 14:41:41 UTC
Permalink
Before the IF...ELSE...ENDIF, I convert the passed parameter to lowercase
(ie. lctable = LOWER(lctable). But my point is that the statement isn't
faling because I added a messagebox to the method to show me which part I
was falling into! The PackTable method is returning the correct value, but
it doesn't seem to make any difference - that's the bit I'm having trouble
with!!
--
_____

This mailbox protected from junk email by MailFrontier Desktop
from MailFrontier, Inc. http://info.mailfrontier.com
Post by Jeroen van Kalken
Since adir() returns filenames in uppercase, your IF statement will
probably fail. (see below)
Post by Debbie
I didn't list all of my code in the message I posted, but I do test to see
if the file can be opened exclusively. If it can't, I let the user know
which table and then move on to the next one listed in the array. I'm not
getting any errors, it's just packing all the tables irrespective of whether
I said it was okay to do so or not!
IF lctable = "table1.dbf" OR lctable = "table2.dbf" OR "table3.dbf" && Etc
IF inlist(lower(lcTable),"table1.dbf", "table2.dbf", "table3.dbf",...)
Post by Debbie
etc
RETURN .F.
ELSE
RETURN .T.
ENDIF
Do you have any other suggestions? Thanks!
proc PackTable
Return inlist((lower(lcTable),"table1.dbf", "table2.dbf",
"table3.dbf",...)
Post by Debbie
Debbie :o)
Post by Craig Berntson
You didn't show the code in the PackTable method. However, if you can't
open the table EXCLUSIVE, you'll get an error. In addition, REINDEX is not
reliable. The key information is stored in the header of the CDX. If that
gets corrupt, REINDEX will either cause an error or create a corrupt index.
--
Craig Berntson
MCSD, Visual FoxPro MVP
www.craigberntson.com
Salt Lake City Fox User Group
www.slcfox.org
www.foxcentral.net
Post by Debbie
I have a reindex program that uses the ADIR() function to gather the names
of all my tables and then reindex them. Before reindexing each table, I
pass the table name to a method which tells me whether or not it is one
that can be packed at this time (it returns .T. if the table can be
packed, and .F. if it can't). My problem is that, regardless of what the
method returns, all tables get packed! I added a messagebox to tell me if
I was falling into the correct part of my code, and I was.
llpack = THISFORMSET.PackTable(lctable)
USE (lctable) EXCL ALIAS lctable
IF llpack
PACK
REINDEX
ELSE
=MESSAGEBOX("Not packing.",0) && Test
REINDEX
ENDIF
USE IN lctable
Maybe I'm missing something silly, but I'd appreciate it if anyone out
there had some suggestions! Thanks in advance.
Debbie
Jeroen van Kalken
2004-11-04 18:39:18 UTC
Permalink
On Thu, 4 Nov 2004 09:41:41 -0500, "Debbie" <***@hotmail.com>
wrote:

How do you determine whether the table gets PACKED or not?
Counting records ?
Searching for deleted records ?
Looking at the file size?
Post by Debbie
Before the IF...ELSE...ENDIF, I convert the passed parameter to lowercase
(ie. lctable = LOWER(lctable). But my point is that the statement isn't
faling because I added a messagebox to the method to show me which part I
was falling into! The PackTable method is returning the correct value, but
it doesn't seem to make any difference - that's the bit I'm having trouble
with!!
Debbie
2004-11-04 23:45:52 UTC
Permalink
There are a handful of tables that I did not want the user to pack during a
reindex procedure, it had nothing to do with whether or not there were
actually any records marked for deletion, just that specific tables should
not be packed at that time. Our client wanted to know which records were
marked for deletion and by whom (ie. the operator logged into the program),
and there is a separate procedure run on a daily basis which will copy out
all the relevant data on deleted records before packing all tables.
--
_____

This mailbox protected from junk email by MailFrontier Desktop
from MailFrontier, Inc. http://info.mailfrontier.com
Post by Jeroen van Kalken
How do you determine whether the table gets PACKED or not?
Counting records ?
Searching for deleted records ?
Looking at the file size?
Post by Debbie
Before the IF...ELSE...ENDIF, I convert the passed parameter to lowercase
(ie. lctable = LOWER(lctable). But my point is that the statement isn't
faling because I added a messagebox to the method to show me which part I
was falling into! The PackTable method is returning the correct value, but
it doesn't seem to make any difference - that's the bit I'm having trouble
with!!
Mike
2004-11-03 22:49:06 UTC
Permalink
Have you stepped through the PackTable method to see why it is always
return true?
Have you checked to make sure that lcTable has a value when being passed
to the PackTable method?
Can you provide the ALL of the code in the PackTable method include the
Parameter statement?
Not sure what part of code you are talking about when you talk about the
messagebox.

-mike
Post by Debbie
I have a reindex program that uses the ADIR() function to gather the names
of all my tables and then reindex them. Before reindexing each table, I
pass the table name to a method which tells me whether or not it is one that
can be packed at this time (it returns .T. if the table can be packed, and
.F. if it can't). My problem is that, regardless of what the method
returns, all tables get packed! I added a messagebox to tell me if I was
falling into the correct part of my code, and I was.
llpack = THISFORMSET.PackTable(lctable)
USE (lctable) EXCL ALIAS lctable
IF llpack
PACK
REINDEX
ELSE
=MESSAGEBOX("Not packing.",0) && Test
REINDEX
ENDIF
USE IN lctable
Maybe I'm missing something silly, but I'd appreciate it if anyone out there
had some suggestions! Thanks in advance.
Debbie
Debbie
2004-11-04 14:50:12 UTC
Permalink
It isn't always returning TRUE! But in reply to your post, I went into the
PackTable method so that I could copy and paste the code in my reply to you,
and I noticed a silly mistake (which is obviously the cause of all my
problems)!! There are eight tables that aren't meant to be packed and one
of them (the one that kept getting packed) was missing the DBF extension in
it's filename. Oops! Guess I need to make an appointment at the
optician's.

Thanks to everyone who replied, and please accept my apologies for wasting
your time.

Debbie
--
_____

This mailbox protected from junk email by MailFrontier Desktop
from MailFrontier, Inc. http://info.mailfrontier.com
Post by Mike
Have you stepped through the PackTable method to see why it is always
return true?
Have you checked to make sure that lcTable has a value when being passed
to the PackTable method?
Can you provide the ALL of the code in the PackTable method include the
Parameter statement?
Not sure what part of code you are talking about when you talk about the
messagebox.
-mike
Post by Debbie
I have a reindex program that uses the ADIR() function to gather the
names of all my tables and then reindex them. Before reindexing each
table, I pass the table name to a method which tells me whether or not it
is one that can be packed at this time (it returns .T. if the table can
be packed, and .F. if it can't). My problem is that, regardless of what
the method returns, all tables get packed! I added a messagebox to tell
me if I was falling into the correct part of my code, and I was.
llpack = THISFORMSET.PackTable(lctable)
USE (lctable) EXCL ALIAS lctable
IF llpack
PACK
REINDEX
ELSE
=MESSAGEBOX("Not packing.",0) && Test
REINDEX
ENDIF
USE IN lctable
Maybe I'm missing something silly, but I'd appreciate it if anyone out
there had some suggestions! Thanks in advance.
Debbie
Loading...