Subject Re: Switch index off
From Mervyn Bick <invalid@invalid.invalid>
Date Tue, 10 Oct 2017 17:15:46 +0200
Newsgroups dbase.getting-started
Attachment(s) test_index.wfm

On 2017-10-10 4:31 PM, Hanspeter wrote:
> Hi, I am seeking on an index without any problem. But when I try to switch the index temporarely off, dBase crashes. In order to swith the index off, I am using following code:
>
> this.rowset.indexName := ""
>
> Even if I am trying thiis.rowset.indexName := null, I get the same problem.
>
> I am working with dBase Plus 2.8. Can someone help me to solve the problem?
> Thanks in advance and regards
> Hanspeter
>

Where is the code in your program?  What error message (if any) did
dBASE show?

'this'  refers to the object executing the code.  In the code you have
posted the only place that the code will do what you expect is if it is
executed in an event handler triggered by the rowset's parent query.

If, for instance, the code is in a pushbutton's onCLick event handler
'this' refers to the pushbutton which doesn't have a rowset object with
a property named indexName.

I no longer have dBASE 2.8 on my computer but the attached little
example, made using dBASE 11.3.1, should work for you.

Mervyn.







if file('test_index.dbf')
  // drop table test_index
endif

if not file('test_index.dbf')
   create table test_index  (id autoinc,data character(15))

   use test_index exclusive
   generate 10
   index on upper(data) tag upper_data
   use
endif  

** END HEADER -- do not remove this line
//
// Generated on 2017-10-10
//
parameter bModal
local f
f = new test_indexForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class test_indexForm of FORM
   with (this)
      height = 21.5
      left = 105.8571
      top = 7.0
      width = 51.2857
      text = ""
   endwith

   this.TEST_INDEX1 = new QUERY()
   this.TEST_INDEX1.parent = this
   with (this.TEST_INDEX1)
      width = 8.0
      height = 1.0
      sql = 'select * from "test_index.DBF"'
      active = true
   endwith

   with (this.TEST_INDEX1.rowset)
      indexName = "UPPER_DATA"
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      dataLink = form.test_index1.rowset
      height = 13.0
      left = 6.0
      top = 1.5
      width = 42.0
   endwith

   this.PUSHBUTTON1 = new PUSHBUTTON(this)
   with (this.PUSHBUTTON1)
      onClick = class::PUSHBUTTON1_ONCLICK
      height = 1.0909
      left = 12.0
      top = 17.0
      width = 22.0
      text = "Disconnect index"
   endwith

   this.PUSHBUTTON2 = new PUSHBUTTON(this)
   with (this.PUSHBUTTON2)
      onClick = class::PUSHBUTTON2_ONCLICK
      height = 1.0909
      left = 12.0
      top = 19.0
      width = 22.0
      text = "Connect index"
   endwith

   this.rowset = this.test_index1.rowset

   function PUSHBUTTON1_onClick()
      form.rowset.indexName := ""
      return

   function PUSHBUTTON2_onClick()
      form.rowset.indexName := "UPPER_DATA"
      return

endclass