Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Memory objects saved into cursors
Message
From
18/02/2019 13:48:58
 
 
To
18/02/2019 13:40:20
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01666501
Message ID:
01666513
Views:
44
>The only issue is I can't effectively "delete" the reference in each array, but can only set it to .NULL. and leave it there until the last one is completed.

Why not? ADEL() command will remove the row from the array. I would first release the object from the array and then use ADEL(). The row count is not changed; the rows are just 'moved' down one in the array so use DIMENSION command to remove the last row. I created a custom collection class for managing like a list but it is actually in an array.
**************************************************
*-- Class Library:  e:\my work\foxpro\projects\common\classes\collection.vcx
**************************************************


**************************************************
*-- Class:        gkkcollection (e:\my work\foxpro\projects\common\classes\collection.vcx)
*-- ParentClass:  label
*-- BaseClass:    label
*-- Time Stamp:   12/19/13 01:20:09 PM
*
*
DEFINE CLASS gkkcollection AS label
	AutoSize = .T.
	Caption = "GKKCollection"
	Height = 17
	Visible = .F.
	Width = 82
	*-- XML Metadata for customizable properties
	_memberdata = [<VFPData><memberdata name="count" type="property" display="Count"/><memberdata name="itemkey" type="property" display="ItemKey"/><memberdata name="items" type="property" display="Items"/><memberdata name="add" type="method" display="Add"/><memberdata name="getitem" type="method" display="GetItem"/><memberdata name="remove" type="method" display="Remove"/><memberdata name="removeall" type="method" display="RemoveAll"/><memberdata name="setkey" type="method" display="SetKey"/><memberdata name="getitemkey" type="method" display="GetItemKey"/></VFPData>]
	*-- Count of items in the collection ***Integer
	count = 0
	Name = "gkkcollection"

	*-- Key of the item added to the collection
	HIDDEN itemkey[1]

	*-- List of Items in collection
	DIMENSION items[1]


	*-- Adds items to the collection
	PROCEDURE add
		LPARAMETERS txItem, tcKey
		LOCAL lnNdx
		IF VARTYPE(tcKey) != "C"
			tcKey = TRANSFORM(tcKey)
		ENDIF
		lnNdx = ASCAN(this.ItemKey, tcKey, 1, this.Count, 1, 15)
		IF lnNdx > 0
			this.Items[lnNdx] = txItem
		ELSE
			this.Count = this.Count + 1
			DIMENSION this.ItemKey[this.Count], this.Items[this.Count]
			this.ItemKey[this.Count] = UPPER(tcKey)
			this.Items[this.Count]   = txItem
		ENDIF
	ENDPROC


	*-- Returns the requested Item index from key
	PROCEDURE getitem
		LPARAMETERS tcItemKey
		LOCAL lnIndex, lnItem
		lnIndex = 0
		IF VARTYPE(tcItemKey) != "C"
			tcItemKey = TRANSFORM(tcItemKey)
		ENDIF
		FOR lnItem=1 TO this.Count
			IF this.ItemKey[lnItem] == UPPER(tcItemKey)
				lnIndex = lnItem
				EXIT
			ENDIF
		ENDFOR
		RETURN lnIndex
	ENDPROC


	*-- Removes selected item from the collection
	PROCEDURE remove
		LPARAMETERS txItem
		IF VARTYPE(txItem) = "N"
			ADEL(this.Items, txItem)
			ADEL(this.ItemKey, txItem)
			this.Count = this.Count - 1
		ELSE
			FOR lnItem=1 TO this.Count
				IF this.ItemKey[lnItem] == UPPER(txItem)
					ADEL(this.Items, lnItem)
					ADEL(this.ItemKey, lnItem)
					this.Count = this.Count - 1
					EXIT
				ENDIF
			ENDFOR
		ENDIF
		IF this.Count > 0
			DIMENSION this.ItemKey[this.Count], this.Items[this.Count]
		ELSE
			DIMENSION this.ItemKey[1], this.Items[1]
		ENDIF
	ENDPROC


	*-- Removes all items from the collection
	PROCEDURE removeall
		this.Count = 0
		DIMENSION this.ItemKey[1], this.Items[1]
		this.ItemKey[1] = .NULL.
		this.Items[1]   = .NULL.
	ENDPROC


	*-- Sets the item key value
	PROCEDURE setkey
		LPARAMETERS tnItem, tcKey
		IF BETWEEN(tnItem, 1, this.Count)
			this.ItemKey[tnItem] = UPPER(tcKey)
		ENDIF
	ENDPROC


	*-- Returns the key for the selected item index
	PROCEDURE getitemkey
		LPARAMETERS tnItem
		IF VARTYPE(tnItem) = "N"
			RETURN this.ItemKey[tnItem]
		ELSE
			RETURN ""
		ENDIF
	ENDPROC


ENDDEFINE
*
*-- EndDefine: gkkcollection
**************************************************
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform