Subject Re: Switch index off
From Akshat Kapoor <akshat.kapoor@kapoorsons.in>
Date Wed, 11 Oct 2017 10:21:23 +0530
Newsgroups dbase.getting-started

Hi Hanspeter,
Were you able to run Mervyn's Code successfully.
If yes then the problem is somewhere else and not on that line.
I had faced similar problem sometime ago with beginappend()
It seems my autonullfields were off and there was a lookuprowset
assigned for one of the fields.
I had to develop a workaround
delink to lookuprowset , beginappend() , assign a valid value to the
field having lookup and reassign the lookuprowset.

So if Mervyn's code did run without error then the error is somewhere
else. So please check that .wfm file (You may have to convert it to
german / build a simple form on same pattern I use only english hence do
not know)

Regards
Akshat

On 10/10/2017 23:56, Hanspeter wrote:
> Hi Mervin,
> thanks for your help and pls. find the code below. My dBase runs in German language and the failure message says that dBase won´t run anymore and there is the choice only to end the program.
>
> If I put a * in front of form.query1.rowset.indexName := "" the index is still on of course and the query runs without any problem. But I would like to switch the index off in order to get a faster query speed. Regards Hanspeter
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>        local fsuch1
>        if mscan=.t.
>           class::xx()
>        endif
>        set procedure to such.wfm additive
>        fsuch1=new einForm()
>        fsuch1.mdi=false
>        fsuch1.text="Scannen"
>        fsuch1.readmodal()
>        mt=fsuch1.entryfield1.value
>        form.tabbox1.cursel:=4
>        form.query1.rowset.indexname:=""
>        ts=seconds()
>        if .not.empty(mt)
>           form.query1.sql = 'select * from ebene where upper(name) like "%&mt%" or upper(direc) LIKE "%&mt%"'
>           form.query1.active:=true
>           form.query1.rowset.first()
>           mscan:=.t.
>        endif
>        close procedure such.wfm
>        fsuch1.release()
>        release mt, ts
>        form.grid1.setfocus()
>        return
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>
>
>
> Mervyn Bick Wrote:
>
>> 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
>>
>