property Items.DefaultItem as HITEM

Retrieves or sets the default item's handle.

 TypeDescription 
   HITEM A long expression that indicates the handle of the item that's used by all properties of the Items object, that have a parameter Item.  

The property is used in VFP implementation. The VFP fires "Invalid Subscript Range" error, while it tries to process a number grater than 65000. Since, the HITEM is a long value that most of the time exceeds 65000, the VFP users have to use this property, instead passing directly the handles to properties. 

The following sample shows to change the cell's image:

.Items.DefaultItem = .Items.AddItem("Item 1")
.Items.CellImage(0,1) = 2

In VFP the following sample fires: "Invalid Subscript Range":

i = .Items.AddItem("Item 1")
.Items.CellImage(i,1) = 2

because the i variable is grater than 65000, and the VFP thinks that the CellImage is an array, but it is not. It is a property. Hope that future versions will correct this problem in VFP.

So, if you pass zero to a property that has a parameter titled Item, the control takes instead the DefaultItem value.

Let's say that your code looks like follows:
LOCAL h
SCAN
	_key="K_"+ALLTRIM(STR(projekte.ID))
	WITH THISFORM.myplan.Items
		h = .AddItem(ALLTRIM(projekte.project_name))
		.AddBar( h,"Project Summary" , DTOT(projekte.sdate),DTOT(projekte.edate), _key, "" )
		.ItemBar( h ,_key,3 ) = "my text"
	ENDWITH
ENDSCAN

The h variable indicates the handle of the newly created item. This value is always greater than 65000, so the VFP environment always fires an error when compiling the AddBar and ItemBar properties because it considers accessing an array, and its limit is 65000. Of course this problem is related to VFP ignoring the fact that it is calling a property! not an array, so our products provide a DefaultItem property that help VFP users to pass this error. So, in VFP the above code should look like follows:

SCAN
	_key="K_"+ALLTRIM(STR(projekte.ID))
	WITH THISFORM.myplan.Items
		.DefaultItem = .AddItem(ALLTRIM(projekte.project_name))
		.AddBar( 0,"Project Summary" , DTOT(projekte.sdate),DTOT(projekte.edate),_key, "" )
		THISFORM.myplan.Template = "Items.ItemBar( 0,`" + _key + "`,3 ) = `my text`"
	ENDWITH
ENDSCAN 

The difference ( marked in red ) is that the first parameter for properties like AddBar and ItemBar is 0, and before calling them the Items.DefaultItem property indicates the handle of the item being accessed. How it works? The control uses the value of the Items.DefaultItem property, when the first parameter of the ItemBar, AddBar and so on is 0. The AddItem property saves before the handle of the newly created item to the DefaultItem property, and so the VFP error is gone, and the code works like you expect.



Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.