Welcome to MSDN Blogs Sign in | Join | Help

Why does the component gallery give an error "Error building key for index"?

We received a bug report:

 

STEPS TO REPRODUCE:

 

1) At the command window, issue the following:

 

Choose Tools->Gallery from the main menu

 

2) If the Visual FoxPro Catalog isn't open, then open it. Click on that

node in the left pane.

 

3) Using the combo box in the upper left, change the selected value from

"Default" to "Class By Type"

 

OBSERVED BEHAVIOR:

 

Error dialog:

 

---------------------------

Component Gallery

---------------------------

Error building key for index "c:\temp\00004utl00bf.cdx" tag "Type".

 

Browser:   classbrowser1

Object:      classbrowser1

Error:         2199

Method:    brwwriteproperties

______________________________

 

Press OK to ignore error and continue.

Press Cancel to close Component Gallery.

---------------------------

OK   Cancel

---------------------------

 

EXPECTED BEHAVIOR:

 

Not this.

 

 

 

What’s happening?

 

The component gallery creates an index, but that index has a variable length index expression:

 

You can see the error line by unzipping Tools\Xsource\Xsource.zip.

See line 4446 in VFPSource\Browser\Browser.prg

 

INDEX ON UPPER(Type)+IIF(EMPTY(Parent)," ",UPPER(PADR(Text,50))) TAG Type

 

The expression has a conditional: with a length of either 1 or 50.

The fix is to make the index key length constant:

 

INDEX ON UPPER(Type+PADR(IIF(EMPTY(Parent),"",Text),50)) TAG Type

 

 

 

Moral: beware of index key expressions of variable length!

 

 

Published Wednesday, April 18, 2007 5:13 PM by Calvin_Hsia
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker