INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Databases and tables

ReBuild your CDX index files by ramani
Posted: 23 Aug 01 (Edited 19 Nov 04)

*********************************************************
** Author Subramanian.G
** Function to rebuild CDX index ... this does....
** First deletes the index and then recreates them
** How to ... =BuildIndex(myDBF)
** Last Modified : 19 November, 2004
*********************************************************
FUNCTION BuildIndex
PARAMETERS myDBF

IF PARAMETERS() # 1
   RETURN .F.
ENDIF

LOCAL laIndex, cKey, cIndex

USE (myDBF)
DIMENSION laIndex(254,3)

*** Load the index name and key names in array
FOR nCount = 1 TO 254
  IF !EMPTY(TAG(nCount))  && Checks for tags in the index
     laIndex(nCount,1) = TAG(nCount) + ' '  &&  tag name
     laIndex(nCount,2) = KEY(nCount) + ' '  &&  Key name
     IF PRIMARY(nCount) && Check Index type
        laIndex(nCount,3) = 'P'    && Primary Index
     ELSE
        IF CANDIDATE(nCount)
           laIndex(nCount,3) = 'C' && Candidate Index
         ELSE
           laIndex(nCount,3) = 'O' && Other Index types
        ENDIF
     ENDIF
  ELSE
     EXIT  && Exit the loop when no more tags are found
  ENDIF
ENDFOR

*** Delete the tags
DELETE TAG ALL

*** Rebuild Index
FOR nCount = 1 TO 254
  IF !EMPTY(laIndex(nCount,1))
     cIndex = ALLT(laIndex(nCount,1))
     cKey = ALLT(laIndex(nCount,2))
     IF laIndex(nCount,3) = 'P'
        ** Create Primary key type
         ALTER TABLE (myDBF) ADD PRIMARY KEY &ckey ;
              TAG &cindex
     ELSE
        IF laIndex(nCount,3)='C'
           && Candidate index
           INDEX ON &cKey TAG &cIndex candidate
        ELSE
           INDEX ON &cKey TAG &cIndex
        ENDIF
     ENDIF
  ELSE
     EXIT  && Exit the loop when no more tags are found
  ENDIF
ENDFOR

USE
RETURN .T.
*********************************************************
** EOF
*********************************************************
** You can cut & paste and use the above function.
** Remember to backup & test this before/after execution.
** Accept it at your own risk.
********************************************************
Hope this helps users

Ramani
FoxAcc Software
(ramani_g@yahoo.com)
Subramanian.G
www.winnersoft.coolfreepages.com
********************************************************
Evaluate this to make others know how useful is this

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close