On Tue, 02 Feb 2010, smu johnson wrote:

Hi,

> When a table's index file is re-opened (it was previously created), does it
> have to evaluate the FOR clause, or can it wait to do that only when a value
> in the table row changes?

It does not need to be evaluated and can wait but it has to be valid
expression which can be compiled by macrocompiler.
Anyhow few times people asked to make such test evaluation to detect
some potential problems like missing functions, incompatible aliases
or not logical results as fast as possible and report RTE before
executed code will start some operations which cannot be finished.
Just like someone asked to delay all such tests as long as possible
because he only wanted to skip using the index created by foreign
application with unknown UDFs in KEY and FOR expressions.
In clipper this behavior depends on used RDD and different RDDs
evaluates KEY and FOR expressions first time in different places.
Similar situation is in xHarbour.

> In SIX, it does not check the FOR expression when it opens an index file.
> In Harbour, when you open the index file it will evaluate the FOR
> expression, and if any variables or functions in that expression are not
> visible, the system will crash (undefined variable/function).

Not crash but generates RTE. You can catch RT errors using BEGIN SEQUENCE
statement.You are right about FOR expression. Harbour DBFCDX evaluates
index KEY and FOR expressions to test their results just after opening
index file. It's CL5.3 DBFCDX / COMIX behavior but CL5.2 DBFCDX / SIXCDX
evaluates only KEY expression when index is open and FOR is evaluated only
when index is updated.

> eg. Index on iif(x=3,"a","b") tag "temp" of test.cdx
> When the index is opened (set index to...) if X is not visible, Harbour will
> crash. In Clipper, it will only crash if a row in the table  changes value
> and the index needs to be updated.

Yes but please use more precise description. RTE is not a crash but
exception which can be fully controlled by programmer. Some important
Clipper features are implemented using RTE, i.e. NETERR() or division
by 0.

> Unfortunately, my code has lots of specialized temporary indexes that are
> created and then used within a specific function. This does not present a
> problem until a timer event fires, which needs to close files to do
> "something". Upon reopening those file before RETURNing back the original
> function, the system crashes because the FOR in the index has variables out
> of scope.
> I can rewrite these but I will probably have to use Private variables and
> non-Static functions.

I'll change early expression evaluation in Harbour SIXCDX driver only
so Harbour SIXCDX will work like CL52 DBFCDX / SIX3 SIXCDX and
Harbour DBFCDX will work like CL53 DBFCDX / COMIX verifying both KEY
and FOR expressions when index is opening.

I'll commit it in a while. You should take current Harbour SVN and
rebuild the compiler binaries.

best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to