On Wed, 22 Apr 2009, Adam Lubszczyk wrote:

Hi,


> Thera are BASE.DBF and BASE.NTX with key  "FunctionX(Field1)"  or key:
> Field1+VariableX
> Make same program with line:
>   USE base INDEX base
> In Clipper it is  OK, I open base with index.

Because during open Clipper does not check if index expressions are valid.
The RTE will appear later when it will have to evaluate some expressions.

> In Harbour I get error "Undefined function FUNCTIONX" or "Variable does not
> exist: VARIABLEX"
> WHY ?

Because Harbour checks if all index expressions (KEY/FOR) are valid when
index is open. It helps to detect problem immediately. IMHO it's much
better then later pseudo random RTE like in Clipper.

> I need FunctionX() or VariableX _only_ if I modify or append record.

Not true. It's necessary to navigate the index. Though in some cases
depending on SHARED/EXCLUSIVE mode and used caches it may be not necessary
for some time.
I guess you created general theory from some situation which happened with
your code but it's not true.

> Maybe I wont only skip by order or seek in base.
> If key is sample "Func1(Field1)+Func2(Field2)+VariableX", 
> I can seek by: DBSEEK( MyFuncEmulateKeyValue() ), I not need Func1(),
> Func2() and VariableX

Try this code with Clipper:

   /*** t01 ***/
   proc main()
      field F
      dbcreate("_tst",{{"F","C",1,0}})
      use _tst
      dbappend(); dbappend(); dbappend()
      index on MYFUNC(F) to _tst
      close
   return
   func myfunc( f )
   return f

to create table and index and this code:

   /*** t02 ***/
   proc main()
      use _tst index _tst
      dbgoto(2)
      while !eof()
         ? recno()
         dbskip()
      enddo
   return

Please note that when you replace
      dbgoto(2)
with:
      dbgoto(1)
it will work without RTE but only in EXCLUSIVE mode. It happens because
record 1 is still active and in exclusive mode is not discarded bu GOTO
operation. In SHARED mode it will always generate RTE.

best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to