Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Collections
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP1
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01040090
Message ID:
01040101
Views:
22
>Can you please give me a code sample to create a multi column collection.
>
>Thanks, Jitendra Shahani

A very simple sample, and there are many ways to do something like this, this is just what I can come up this late :)
loTestCollection	= CREATEOBJECT('Collection')
WITH loTestCollection as Collection
	.Add(newTestObject('Name_001', 'One'), 'Key_001')
	.Add(newTestObject('Name_002', 'Two'), 'Key_002')
	.Add(newTestObject('Name_003', 'Three'), 'Key_003')
	.Add(newTestObject('Name_004', 'Four'), 'Key_004')
ENDWITH

FOR EACH loTestObject IN loTestCollection
	WITH loTestObject
		? .Class, .Name, .Value
	ENDWITH
ENDFOR


FUNCTION newTestObject(tcName, tcValue)

LOCAL loTest

loTest		= CREATEOBJECT('Empty')

ADDPROPERTY(loTest, 'Class', 'TestObject')
ADDPROPERTY(loTest, 'Name', tcName)
ADDPROPERTY(loTest, 'Value', tcValue)

RETURN loTest
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform