Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursors vs. Arrays vs. Collections
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00864266
Message ID:
00865305
Views:
17
>Just to make sure I'm following you, do you want to explain that?
>
>
>>>I'm preparing a presentation next week for my user group and want some ideas for when to use cursors, arrays, and collections rather than one of the others.
>>
>>You might also want to mention the use of the _screen object.
>>
>>John

Well, it's not an array, or cursor or collection, but I just thought you might want to mention it a another data structure. I use it all the time for a global application object. I have an app that when the user logs in, I create a _screen.lcuser property and populate with the username. I also create a handful of other properties, but you get the idea. From there on, it's always available. It's also a very short route to the info. I don't have to iterate anything.

Here's an example of what I'm doing:
IF VAL(OS(3))>=4

	*** gets info for the local machine using wmi scripting
	NULL=.NULL.

	objWMIService = GETOBJECT("winmgmts:\\")
	*!*	colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
	*!*	For Each objItem In colItems
	*!*	? objItem.Name
	*!*	 ?objItem.CurrentClockSpeed
	*!*	NEXT
	colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
	FOR EACH objItem IN colItems
		lcnotebookusername=objItem.UserName
		lcnotebookmanufacturer= objItem.Manufacturer
		lcnotebookmodel=objItem.Model
	NEXT
	colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
	FOR EACH objItem IN colItems
		lcnotebookserialnumber=objItem.SerialNumber
		lcnotebookversion=objItem.VERSION
		lcnotebookinstalldate=objItem.InstallDate
	NEXT
	_SCREEN.ADDPROPERTY('lcnotebookmodel',lcnotebookmodel)
	_SCREEN.ADDPROPERTY('lcnotebookmanufacturer',lcnotebookmanufacturer)
	_SCREEN.ADDPROPERTY('lcnotebookserialnumber',lcnotebookserialnumber)
	_SCREEN.ADDPROPERTY('lcnotebookusername',lcnotebookusername)
	_SCREEN.ADDPROPERTY('lcnotebookinstalldate',lcnotebookinstalldate)
	_SCREEN.ADDPROPERTY('lcnotebookversion',lcnotebookversion)
	objWMIService = NULL
	colItems = NULL
	AMEMBERS(la,_SCREEN,1)
	CREATE CURSOR LCXML (DESCRIP C(15),DATA C(20))
	FOR i = 1 TO ALEN(la,1)
		LC=la(i)
		IF LC='LCNOTEBOOK'
			LCVAR='_SCREEN.'+LC
			m.descrip=STRTRAN(LCVAR,'_SCREEN.LCNOTEBOOK','')
			STORE &LCVAR TO M.DATA
			IF !ISNULL(M.DATA)
				INSERT INTO LCXML FROM MEMVAR
			ENDIF
		ENDIF
	ENDFOR
	*? OS(3)
	CURSORTOXML("LCXML", "myXMLFile.xml", 1, 512, 0, "1")
	_SCREEN.ADDPROPERTY('LCXMLINFO','')
	_SCREEN.LCXMLINFO=FILETOSTR('MYXMLFILE.XML')
	USE IN LCXML
	ERASE MYXMLFILE.XML
	RELEASE la
ENDIF
John
John Harvey
Shelbynet.com

"I'm addicted to placebos. I could quit, but it wouldn't matter." Stephen Wright
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform