What is correct way to use checkindex within an application

316 views
Skip to first unread message

Gestbiz

unread,
Feb 20, 2013, 6:03:46 AM2/20/13
to multisoft...@googlegroups.com
I am having some difficulties to implement RTE 331 error control 
I used the following code

 IF INDEXCHECK(1) > 0 .or. INDEXCHECK(2) > 0

it does not work for RTE 331 errors .

According to the manual I should compile and use checkindex.exe
for the RTE 331.error
which I did and placed that exe file in the same directory of the datas

I included the following line of code in my application just after opening of an index

Run checkindex filename indexname

I got no concrete results.

Any recommendations from the members of this forum ?

Thanks

Paul

unread,
Feb 20, 2013, 6:58:24 AM2/20/13
to
You of course need opended database and indices to check them. For example:

if !file("address.dbf")
   ? "Creating address.dbf"
   dbcreate("address", {{"id","n",6,0},{"name","c",25,0},
{"first","c",25,0}, ;
                        {"address","c",25,0}, {"zip","n",6,0}, {"city","C",25,0}} )
endif
if !file("address_id.idx") .or. !file("
address_name.idx")
   USE address NEW
   INDEX ON id   to address_id
   INDEX ON name to address_name
   USE
endif
USE address index address_id, address_name SHARED NEW
if indexcheck(1) > 0 .or. indexcheck(2) > 0
   ? "Reindexing", dbf()
   USE
   USE address index address_id, address_name EXCLUSIVE
   REINDEX
   USE address index address_id, address_name SHARED
endif
? dbf(), used(), neterr()
wait

Hope this helps you.
Paul

Angelos Christodoulou

unread,
Feb 20, 2013, 6:33:47 AM2/20/13
to multisoft...@googlegroups.com

We have written a function that checks validity of index file on opening and fixes on-the-fly

Unsure if the entire group are interested in this – but willing to share if you want to mail me direct – angelos at accpick.co.za

 

Angelos Christodoulou

Cell:   +27 82 491 0964

Tel:    +27 33 343 6000

Fax1: +27 33 343 6001

Fax2: +27 86 6760496

Web: www.accpick.co.za

Description: C:\Users\Angelos\Documents\Angelos signature_files\image002.jpg

Description: C:\Users\Angelos\Documents\Angelos signature_files\image004.jpg

--
You received this message because you are subscribed to the Google
Groups "multisoft FlagShip" group. To post to this group, send email
to multisoft...@googlegroups.com. To unsubscribe from this
group, send email to multisoft-flags...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/multisoft-flagship?hl=en.
---
You received this message because you are subscribed to the Google Groups "multisoft FlagShip" group.
To unsubscribe from this group and stop receiving emails from it, send an email to multisoft-flags...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.2238 / Virus Database: 2639/5617 - Release Date: 02/19/13

image001.jpg
image002.jpg

Gestbiz

unread,
Feb 20, 2013, 7:51:23 AM2/20/13
to multisoft...@googlegroups.com
Thanks for sharing - for more understanding below is what I am using for code any comments about the coding below
 

OpenClient()

Function OpenClient()
local aFields := {}
SET OPENERROR OFF                    // don't display RTE on open failure
 
if !file("gbclient.dbf")              // database available?
   aadd(aFields,{'cat       ', 'C',  4,0})
   aadd(aFields,{'cust_no   ', 'C',  6,0})
   aadd(aFields,{'cust_name ', 'C', 50,0})
   aadd(aFields,{'cust_cat  ', 'C',  4,0})
   aadd(aFields,{'geocode   ', 'C',  7,0})
   aadd(aFields,{'adress1   ', 'C', 30,0})
   aadd(aFields,{'adress2   ', 'C', 30,0})
   aadd(aFields,{'tel       ', 'C', 17,0})
   aadd(aFields,{'incharge  ', 'C', 40,0})
   aadd(aFields,{'baldate   ', 'D',  8,0})
   aadd(aFields,{'balancedue', 'N', 12,2})
   aadd(aFields,{'balance_us', 'N', 12,2})
   aadd(aFields,{'dbal_us   ', 'D',  8,0})
   aadd(aFields,{'date_new  ', 'D',  8,0})
   aadd(aFields,{'stat      ', 'C',  1,0})
   aadd(aFields,{'grp       ', 'C',  1,0})
   aadd(aFields,{'last_inv  ', 'C',  8,0})
   aadd(aFields,{'inv_value ', 'N', 11,2})
   aadd(aFields,{'inv_date  ', 'D',  8,0})
   aadd(aFields,{'email     ', 'C', 40,0})
   aadd(aFields,{'comp      ', 'C',  1,0})
   aadd(aFields,{'cred_type ', 'C',  1,0})
   aadd(aFields,{'cred_lim  ', 'N', 11,2})
   aadd(aFields,{'charges   ', 'N',  9,2})
   aadd(aFields,{'init_bal  ', 'N', 11,2})
   aadd(aFields,{'init_date ', 'D',  8,0})
   aadd(aFields,{'init_balus', 'N', 11,2})
   aadd(aFields,{'init_dateu', 'D',  8,0})
   aadd(aFields,{'lastpayh  ', 'N', 11,2})
   aadd(aFields,{'lastpayh_d', 'D',  8,0})
   aadd(aFields,{'lastpayus ', 'N', 11,2})
   aadd(aFields,{'lastpayusd', 'D',  8,0})
   aadd(aFields,{'vendeur   ', 'C',  3,0})
   aadd(aFields,{'avanceg   ', 'N', 11,2})
   aadd(aFields,{'avanceu   ', 'N', 11,2})
   aadd(aFields,{'adeposerg ', 'N', 11,2})
   aadd(aFields,{'adeposeru ', 'N', 11,2})
   aadd(aFields,{'nif ', 'C', 24,0})
   DbCreate("gbclient", aFields)      // create new database
   use gbclient SHARED new alias clients
else
  nFOpen := myDbfCheckOpen("clients")
if nFOpen = 0
  // if not already open - open it
 use gbclient SHARED new alias clients
else
     // database already open 
     // select it in the working area to use it   
endif
ENDIF
select clients
// check if all index are ok 
if INDEXCHECK(1) > 0 .or. INDEXCHECK(2) > 0 .or. ;
      !file("gbclien1.idx") .or. ;
      !file("gbclien2.idx") .or. ;
      !file("gbclien3.idx") .or. ;
      !file("gbclien4.idx") 

   select clients
   index on cust_no   to gbclien1                                                                                                       // 
   index on cust_name to gbclien2 
   index on geocode   to gbclien3 
   index on cust_cat  to gbclien4           
endif
if neterr()
   alert("could not open 'categ?.idx', check permission")
   my_use ("clients",, .T., .F.) // USE..EXCLUSIVE
endif
SET INDEX TO gbclien1,gbclien2,gbclien3,gbclien4    
GO TOP                              // go to first logical record

return

Paul

unread,
Feb 20, 2013, 8:18:53 AM2/20/13
to
You have not read my previous posting nor the FlagShip manual in fully. At the time of your INDEXCHECK() invocation, you have opened the database without indices.
Paul


Gestbiz

unread,
Apr 9, 2013, 3:56:31 PM4/9/13
to multisoft...@googlegroups.com
In the above example/model posted by Paul,
I noticed that the index gets updated every time the file is open.

Is that normal.?

I am applying this model for all my files.
I end up having all the files reindexed every time a user is logged in the system.

Can anybody comment on this?

Thanks 
Reginald



Paul

unread,
Apr 10, 2013, 11:28:35 AM4/10/13
to multisoft...@googlegroups.com
The statement

    if !file("address_id.idx") .or. !file("address_name.idx")
checks if both index files exists and if not so, following commands performs the indexing.

The statement

   if indexcheck(1) > 0 .or. indexcheck(2) > 0
checks for the index integrity (corruption) vs. database. See further details in the manual section FUN.indexcheck()

Best regards,
Paul

Gestbiz

unread,
Apr 10, 2013, 12:36:18 PM4/10/13
to multisoft...@googlegroups.com
Is it normal Paul ,
that time stamp of the index file changes every time you call the routine?

Sent from my iPad

Paul

unread,
Apr 12, 2013, 10:42:52 AM4/12/13
to multisoft...@googlegroups.com
Any file has three time stamps: creation, modification and last access. All these stamps are managed by the operating system (OS). Usually, only the modification date/time is displayed.
If you modify the database by REPLACE etc, it becomes new modification time stamp by the OS. The same is valid for attached indices, where the stamp is also changed by INDEX ON, REINDEX etc.

Paul
Reply all
Reply to author
Forward
0 new messages