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!


 


 

Comments (0)

Skip to main content